"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowerCAmelCase_     =	{
    '''configuration_mobilenet_v2''': [
        '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''MobileNetV2Config''',
        '''MobileNetV2OnnxConfig''',
    ],
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase_     =	['''MobileNetV2FeatureExtractor''']
						lowerCAmelCase_     =	['''MobileNetV2ImageProcessor''']


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase_     =	[
						    '''MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''MobileNetV2ForImageClassification''',
						    '''MobileNetV2ForSemanticSegmentation''',
						    '''MobileNetV2Model''',
						    '''MobileNetV2PreTrainedModel''',
						    '''load_tf_weights_in_mobilenet_v2''',
						]


if TYPE_CHECKING:
						from .configuration_mobilenet_va import (
						    MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    MobileNetVaConfig,
						    MobileNetVaOnnxConfig,
						)

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_mobilenet_va import MobileNetVaFeatureExtractor
												from .image_processing_mobilenet_va import MobileNetVaImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_mobilenet_va import (
												    MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MobileNetVaForImageClassification,
												    MobileNetVaForSemanticSegmentation,
												    MobileNetVaModel,
												    MobileNetVaPreTrainedModel,
												    load_tf_weights_in_mobilenet_va,
												)


else:
						import sys

						lowerCAmelCase_     =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



"""simple docstring"""





import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"M-CLIP"





				def __init__(      self							:							Optional[Any]      ,    _A							:							List[str]=1_0_2_4      ,    _A							:							Union[str, Any]=7_6_8      ,    **_A							:							Optional[Any]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						Tuple			  =    transformerDimSize
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    imageDimSize
											super().__init__(**_A)




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						MCLIPConfig





				def __init__(      self							:							Dict      ,    _A							:							Optional[Any]      ,    *_A							:							Any      ,    **_A							:							Dict):



											"""simple docstring"""







											super().__init__(_A      ,    *_A      ,    **_A)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    XLMRobertaModel(_A)
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    torch.nn.Linear(
											    in_features=config.transformerDimensions      ,    out_features=config.numDims)





				def 		_lowerCAmelCase		(      self							:							Union[str, Any]      ,    _A							:							str      ,    _A							:							int):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						str			  =    self.transformer(input_ids=_A      ,    attention_mask=_A)[0]
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    (embs * attention_mask.unsqueeze(2)).sum(dim=1) / attention_mask.sum(dim=1)[:, None]
											return self.LinearTransformation(_A), embs


