"""simple docstring"""






import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel

class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					a   	=		"M-CLIP"



					def __init__(						self			:				int   , _snake_case			:				int=1024   , _snake_case			:				Optional[int]=768   , **_snake_case			:				str		)							->       List[str]:
									SCREAMING_SNAKE_CASE__		  =				transformerDimSize
									SCREAMING_SNAKE_CASE__		  =				imageDimSize
									super().__init__(**_snake_case		)



class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					a   	=		MCLIPConfig



					def __init__(						self			:				Optional[Any]   , _snake_case			:				Dict   , *_snake_case			:				int   , **_snake_case			:				List[Any]		)							->       Union[str, Any]:
									super().__init__(_snake_case   , *_snake_case   , **_snake_case		)
									SCREAMING_SNAKE_CASE__		  =				XLMRobertaModel(_snake_case		)
									SCREAMING_SNAKE_CASE__		  =				torch.nn.Linear(
									    in_features=config.transformerDimensions   , out_features=config.numDims		)



					def 			lowerCAmelCase_					(						self			:				Union[str, Any]   , _snake_case			:				Dict   , _snake_case			:				List[str]		)							->       Union[str, Any]:
									SCREAMING_SNAKE_CASE__		  =				self.transformer(input_ids=_snake_case   , attention_mask=_snake_case		)[0]
									SCREAMING_SNAKE_CASE__		  =				(embs * attention_mask.unsqueeze(2		)).sum(dim=1		) / attention_mask.sum(dim=1		)[:, None]
									return self.LinearTransformation(_snake_case		), embs





"""simple docstring"""






from typing import TYPE_CHECKING

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


_A   					=    {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']}


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_A   					=    [
						    'VAN_PRETRAINED_MODEL_ARCHIVE_LIST',
						    'VanForImageClassification',
						    'VanModel',
						    'VanPreTrainedModel',
						]

if TYPE_CHECKING:
						from .configuration_van import VAN_PRETRAINED_CONFIG_ARCHIVE_MAP, VanConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_van import (
												    VAN_PRETRAINED_MODEL_ARCHIVE_LIST,
												    VanForImageClassification,
												    VanModel,
												    VanPreTrainedModel,
												)

else:
						import sys

						_A   					=    _LazyModule(__name__, globals()['__file__'], _import_structure)




