

'''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__,    UpperCAmelCase__			)     ->     bool:
       A_		   = len(UpperCAmelCase__			)
       A_		   = [[False] * (required_sum + 1) for _ in range(arr_len + 1			)]

       # for each arr value, a sum of zero(0) can be formed by not taking any element
       # hence True/1
       for i in range(arr_len + 1			):
              A_		   = True

       # sum is not zero and set is empty then false
       for i in range(1,    required_sum + 1			):
              A_		   = False

       for i in range(1,    arr_len + 1			):
              for j in range(1,    required_sum + 1			):
                     if arr[i - 1] > j:
                            A_		   = subset[i - 1][j]
                     if arr[i - 1] <= j:
                            A_		   = subset[i - 1][j] or subset[i - 1][j - arr[i - 1]]

       return subset[arr_len][required_sum]


if __name__ == "__main__":
      import doctest

      doctest.testmod()
