

"""simple docstring"""




import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel







class   __lowercase      (     UpperCamelCase_       ):
  snake_case_												=							"""M-CLIP"""

  def __init__(	self		:      Any       ,A		:      Tuple=1_024       ,A		:      Dict=768       ,**A		:      Optional[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	int        =       transformerDimSize
   UpperCAmelCase__       :	Union[str, Any]        =       imageDimSize
   super().__init__(**a__     )







class   __lowercase      (     UpperCamelCase_       ):
  snake_case_												=							MCLIPConfig

  def __init__(	self		:      Optional[Any]       ,A		:      Optional[int]       ,*A		:      Any       ,**A		:      int     ):






   '''simple docstring'''
   super().__init__(a__       ,*a__       ,**a__     )
   UpperCAmelCase__       :	Any        =       XLMRobertaModel(a__     )
   UpperCAmelCase__       :	List[Any]        =       torch.nn.Linear(
       in_features=config.transformerDimensions       ,out_features=config.numDims     )




  def  __lowercase							(	self		:      Dict       ,A		:      str       ,A		:      List[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Dict        =       self.transformer(input_ids=a__       ,attention_mask=a__     )[0]
   UpperCAmelCase__       :	Tuple        =       (embs * attention_mask.unsqueeze(2     )).sum(dim=1     ) / attention_mask.sum(dim=1     )[:, None]
   return self.LinearTransformation(a__     ), embs







'''simple docstring'''

def        UpperCAmelCase_ (  lowerCamelCase_			):







 """simple docstring"""


 return number & 1 == 0


if __name__ == "__main__":
     import doctest

     doctest.testmod()





