

"""simple docstring"""


import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel





class lowerCamelCase__   (				SCREAMING_SNAKE_CASE_    ):



    '''simple docstring'''




    _lowerCamelCase					=   '''M-CLIP'''




    def __init__( self ,lowerCamelCase_=1_0_2_4 ,lowerCamelCase_=7_6_8 ,**lowerCamelCase_    )    ->      Any:
          A				  =		transformerDimSize
          A				  =		imageDimSize
          super().__init__(**snake_case__    )





class lowerCamelCase__   (				SCREAMING_SNAKE_CASE_    ):



    '''simple docstring'''




    _lowerCamelCase					=   MCLIPConfig




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




    def UpperCamelCase__		( self ,lowerCamelCase_ ,lowerCamelCase_    )    ->      Union[str, Any]:
          A				  =		self.transformer(input_ids=snake_case__ ,attention_mask=snake_case__    )[0]
          A				  =		(embs * attention_mask.unsqueeze(2    )).sum(dim=1    ) / attention_mask.sum(dim=1    )[:, None]
          return self.LinearTransformation(snake_case__    ), embs








'''simple docstring'''







from ..utils import DummyObject, requires_backends
class 						UpperCamelCase__       (			metaclass=SCREAMING_SNAKE_CASE_						):



     """simple docstring"""






     __magic_name__           =     ["torch", "torchsde"]







     def __init__(			self   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(self   ,						['torch', 'torchsde'] )







     @classmethod
     def a						(			cls   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(cls   ,						['torch', 'torchsde'] )







     @classmethod
     def a						(			cls   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(cls   ,						['torch', 'torchsde'] )

