

'''simple docstring'''







import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel


class    A__ ( _snake_case     ):
    lowercase		   =						"M-CLIP"



    def __init__(   self						,			UpperCamelCase__=1024						,			UpperCamelCase__=768						,			**UpperCamelCase__    )  -> str:





           '''simple docstring'''
           A_		   = transformerDimSize
           A_		   = imageDimSize
           super().__init__(**UpperCamelCase__    )


class    A__ ( _snake_case     ):
    lowercase		   =						MCLIPConfig



    def __init__(   self						,			UpperCamelCase__						,			*UpperCamelCase__						,			**UpperCamelCase__    )  -> List[Any]:





           '''simple docstring'''
           super().__init__(UpperCamelCase__						,			*UpperCamelCase__						,			**UpperCamelCase__    )
           A_		   = XLMRobertaModel(UpperCamelCase__    )
           A_		   = torch.nn.Linear(
               in_features=config.transformerDimensions						,			out_features=config.numDims    )







    def    snake_case_     (   self						,			UpperCamelCase__						,			UpperCamelCase__    )  -> str:





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



'''simple docstring'''







def  UpperCAmelCase__      ( UpperCAmelCase__			)     ->     float:

       if edge <= 0 or not isinstance(UpperCAmelCase__,    UpperCAmelCase__			):
              raise ValueError("""Length must be a positive."""			)
       return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2)
def  UpperCAmelCase__      ( UpperCAmelCase__			)     ->     float:

       if edge <= 0 or not isinstance(UpperCAmelCase__,    UpperCAmelCase__			):
              raise ValueError("""Length must be a positive."""			)
       return ((15 + (7 * (5 ** (1 / 2)))) / 4) * (edge**3)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
