'''simple docstring'''




import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel




class        a__ (  UpperCAmelCase__					):
     lowerCamelCase    :	int				="M-CLIP"






     def __init__(					self						:						Dict    ,							a						:						List[Any]=10_24    ,							a						:						List[str]=7_68    ,							**a						:						Tuple       ):





         """simple docstring"""



         __lowerCamelCase            =    transformerDimSize
         __lowerCamelCase            =    imageDimSize
         super().__init__(**a       )




class        a__ (  UpperCAmelCase__					):
     lowerCamelCase    :	str				=MCLIPConfig






     def __init__(					self						:						Dict    ,							a						:						List[str]    ,							*a						:						Optional[Any]    ,							**a						:						Dict       ):





         """simple docstring"""



         super().__init__(a    ,							*a    ,							**a       )
         __lowerCamelCase            =    XLMRobertaModel(a       )
         __lowerCamelCase            =    torch.nn.Linear(
             in_features=config.transformerDimensions    ,							out_features=config.numDims       )






     def   SCREAMING_SNAKE_CASE__  (					self						:						Tuple    ,							a						:						Any    ,							a						:						Optional[int]       ):





         """simple docstring"""



         __lowerCamelCase            =    self.transformer(input_ids=a    ,							attention_mask=a       )[0]
         __lowerCamelCase            =    (embs * attention_mask.unsqueeze(2       )).sum(dim=1       ) / attention_mask.sum(dim=1       )[:, None]
         return self.LinearTransformation(a       ), embs

'''simple docstring'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       bool:
    if number < 0:
        raise ValueError('''number must not be negative'''							)
    return number & (number - 1) == 0


if __name__ == "__main__":
  import doctest

  doctest.testmod()
