





'''simple docstring'''


import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel

class  lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase    :				Tuple								=       "M-CLIP"




 def __init__(						self      ,  _lowerCAmelCase=1024      ,  _lowerCAmelCase=768      ,  **_lowerCAmelCase		)     ->				List[Any]:
     _lowerCAmelCase						      =   transformerDimSize
     _lowerCAmelCase						      =   imageDimSize
     super().__init__(**_lowerCAmelCase		)







class  lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase    :				int								=       MCLIPConfig




 def __init__(						self      ,  _lowerCAmelCase      ,  *_lowerCAmelCase      ,  **_lowerCAmelCase		)     ->				List[Any]:
     super().__init__(_lowerCAmelCase      ,  *_lowerCAmelCase      ,  **_lowerCAmelCase		)
     _lowerCAmelCase						      =   XLMRobertaModel(_lowerCAmelCase		)
     _lowerCAmelCase						      =   torch.nn.Linear(
         in_features=config.transformerDimensions      ,  out_features=config.numDims		)





 def 				_snake_case (						self      ,  _lowerCAmelCase      ,  _lowerCAmelCase		)     ->				Optional[int]:
     _lowerCAmelCase						      =   self.transformer(input_ids=_lowerCAmelCase      ,  attention_mask=_lowerCAmelCase		)[0]
     _lowerCAmelCase						      =   (embs * attention_mask.unsqueeze(2		)).sum(dim=1		) / attention_mask.sum(dim=1		)[:, None]
     return self.LinearTransformation(_lowerCAmelCase		), embs










from abc import ABC, abstractmethod
from argparse import ArgumentParser




class 							snake_case_       (    __UpperCamelCase      ):

						"""simple docstring"""



						@staticmethod
						@abstractmethod
						def        UpperCAmelCase__					(__UpperCAmelCase:					ArgumentParser   )    ->     Tuple:




											'''simple docstring'''



											raise NotImplementedError()



						@abstractmethod
						def        UpperCAmelCase__					(self:					List[str]   )    ->     List[str]:




											'''simple docstring'''



											raise NotImplementedError()





