



from __future__ import annotations
def  snake_case						(__lowercase ,      __lowercase ,      __lowercase						)	->	int | float:

						'''simple docstring'''



						if len(_A						) == 0:
												raise ValueError("find_max() arg is an empty sequence"						)
						if (
						    left >= len(_A						)
						    or left < -len(_A						)
						    or right >= len(_A						)
						    or right < -len(_A						)
						):
												raise IndexError("list index out of range"						)
						if left == right:
												return nums[left]
						_snake_case						:					str    =   (left + right) >> 1  # the middle
						_snake_case						:					List[str]    =   find_max(_A ,      _A ,      _A						)  # find max in range[left, mid]
						_snake_case						:					Tuple    =   find_max(_A ,      mid + 1 ,      _A						)  # find max in range[mid + 1, right]

						return left_max if left_max >= right_max else right_max


if __name__ == "__main__":
				import doctest

				doctest.testmod(verbose=True)
import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel



class        lowercase_   (					__snake_case		):
							_lowerCamelCase						=		'M-CLIP'



							def __init__(						self				,    lowercase_=1_024				,    lowercase_=768				,    **lowercase_    ):
													_snake_case						:					str    =   transformerDimSize
													_snake_case						:					Union[str, Any]    =   imageDimSize
													super().__init__(**lowercase_    )




class        lowercase_   (					__snake_case		):
							_lowerCamelCase						=		MCLIPConfig



							def __init__(						self				,    lowercase_				,    *lowercase_				,    **lowercase_    ):
													super().__init__(lowercase_				,    *lowercase_				,    **lowercase_    )
													_snake_case						:					List[Any]    =   XLMRobertaModel(lowercase_    )
													_snake_case						:					int    =   torch.nn.Linear(
													    in_features=config.transformerDimensions				,    out_features=config.numDims    )



							def 	UpperCamelCase	(						self				,    lowercase_				,    lowercase_    ):
													_snake_case						:					Tuple    =   self.transformer(input_ids=lowercase_				,    attention_mask=lowercase_    )[0]
													_snake_case						:					Tuple    =   (embs * attention_mask.unsqueeze(2    )).sum(dim=1    ) / attention_mask.sum(dim=1    )[:, None]
													return self.LinearTransformation(lowercase_    ), embs