




"""simple docstring"""


import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel


class _lowerCamelCase    (					a_						):
   _lowerCamelCase    :int     				=     "M-CLIP"






   def __init__(		self       :		Optional[Any]   ,     UpperCamelCase       :		List[Any]=10_24   ,     UpperCamelCase       :		Optional[Any]=7_68   ,     **UpperCamelCase       :		str   )			->						List[str]:

         """simple docstring"""
         lowerCAmelCase__      :			int   =	transformerDimSize
         lowerCAmelCase__      :			Dict   =	imageDimSize
         super().__init__(**UpperCamelCase   )






class _lowerCamelCase    (					a_						):
   _lowerCamelCase    :List[Any]     				=     MCLIPConfig






   def __init__(		self       :		Optional[int]   ,     UpperCamelCase       :		List[str]   ,     *UpperCamelCase       :		Tuple   ,     **UpperCamelCase       :		Any   )			->						Dict:

         """simple docstring"""
         super().__init__(UpperCamelCase   ,     *UpperCamelCase   ,     **UpperCamelCase   )
         lowerCAmelCase__      :			Union[str, Any]   =	XLMRobertaModel(UpperCamelCase   )
         lowerCAmelCase__      :			str   =	torch.nn.Linear(
             in_features=config.transformerDimensions   ,     out_features=config.numDims   )






   def 	_lowerCAmelCase   (		self       :		List[str]   ,     UpperCamelCase       :		int   ,     UpperCamelCase       :		Union[str, Any]   )			->						Optional[int]:

         """simple docstring"""
         lowerCAmelCase__      :			List[str]   =	self.transformer(input_ids=UpperCamelCase   ,     attention_mask=UpperCamelCase   )[0]
         lowerCAmelCase__      :			str   =	(embs * attention_mask.unsqueeze(2   )).sum(dim=1   ) / attention_mask.sum(dim=1   )[:, None]
         return self.LinearTransformation(UpperCamelCase   ), embs











"""simple docstring"""


def 	lowercase_				(			__UpperCAmelCase				)						->    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__      :			List[str]   =	""""""
      while len(__UpperCAmelCase				) % 3 != 0:
            lowerCAmelCase__      :			Optional[Any]   =	"""0""" + bin_string
      lowerCAmelCase__      :			List[Any]   =	[
          bin_string[index : index + 3]
          for index in range(len(__UpperCAmelCase				)				)
          if index % 3 == 0
      ]
      for bin_group in bin_string_in_3_list:
            lowerCAmelCase__      :			Optional[int]   =	0
            for index, val in enumerate(__UpperCAmelCase				):
                  oct_val += int(2 ** (2 - index) * int(__UpperCAmelCase				)				)
            oct_string += str(__UpperCAmelCase				)
      return oct_string


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

  testmod()





