



'''simple docstring'''
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel



class _A     (			SCREAMING_SNAKE_CASE_			):
		_SCREAMING_SNAKE_CASE    :			Optional[int]  					=	"M-CLIP"





		def __init__(   self       ,				__UpperCAmelCase=1_024       ,				__UpperCAmelCase=768       ,				**__UpperCAmelCase )				->   Optional[int]:

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



class _A     (			SCREAMING_SNAKE_CASE_			):
		_SCREAMING_SNAKE_CASE    :			Tuple  					=	MCLIPConfig





		def __init__(   self       ,				__UpperCAmelCase       ,				*__UpperCAmelCase       ,				**__UpperCAmelCase )				->   Dict:

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





		def 							__A				(   self       ,				__UpperCAmelCase       ,				__UpperCAmelCase )				->   Union[str, Any]:

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









'''simple docstring'''





def        a_     (							_lowerCAmelCase       )      ->      str:
  if not all(char in '01' for char in bin_string       ):
    raise ValueError('Non-binary value was passed to the function'       )
  if not bin_string:
    raise ValueError('Empty string was passed to the function'       )
  __lowerCamelCase       :       int           = ''
  while len(_lowerCAmelCase       ) % 3 != 0:
    __lowerCamelCase       :       str           = '0' + bin_string
  __lowerCamelCase       :       Union[str, Any]           = [
      bin_string[index : index + 3]
      for index in range(len(_lowerCAmelCase       )       )
      if index % 3 == 0
  ]
  for bin_group in bin_string_in_3_list:
    __lowerCamelCase       :       Tuple           = 0
    for index, val in enumerate(_lowerCAmelCase       ):
      oct_val += int(2 ** (2 - index) * int(_lowerCAmelCase       )       )
    oct_string += str(_lowerCAmelCase       )
  return oct_string


if __name__ == "__main__":
   from doctest import testmod

   testmod()






