"""simple docstring"""




def   UpperCAmelCase					(	UpperCamelCase__				):






							"""simple docstring"""





							A__	     =							abs(__UpperCamelCase				)
							A__	     =							0
							while n > 0:
														res += n % 10
														n //= 10
							return res






def   UpperCAmelCase					(	UpperCamelCase__				):






							"""simple docstring"""





							A__	     =							abs(__UpperCamelCase				)
							return n if n < 10 else n % 10 + sum_of_digits(n // 10				)






def   UpperCAmelCase					(	UpperCamelCase__				):






							"""simple docstring"""





							return sum(int(__UpperCamelCase				) for c in str(abs(__UpperCamelCase				)				)				)






def   UpperCAmelCase					(	):






							"""simple docstring"""





							from collections.abc import Callable
							from timeit import timeit

							def benchmark_a_function(UpperCamelCase__       ,    UpperCamelCase__				) -> None:
														A__	     =							F'''{func.__name__}({value})'''
														A__	     =							timeit(F'''__main__.{call}'''       ,    setup='import __main__'				)
														print(F'''{call:56} = {func(__UpperCamelCase				)} -- {timing:.4f} seconds'''				)

							for value in (262_144, 1_125_899_906_842_624, 1_267_650_600_228_229_401_496_703_205_376):
														for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
																					benchmark_a_function(__UpperCamelCase       ,    __UpperCamelCase				)
														print()


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		benchmark()






"""simple docstring"""




import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel
class     UpperCamelCase__(			__A ):
						lowerCAmelCase__  :						Union[str, Any]													=		'M-CLIP'





						def __init__(       self		,__UpperCAmelCase=10_24		,__UpperCAmelCase=7_68		,**__UpperCAmelCase     )					->				List[str]:
													A__	     =							transformerDimSize
													A__	     =							imageDimSize
													super().__init__(**__UpperCAmelCase     )






class     UpperCamelCase__(			__A ):
						lowerCAmelCase__  :						Union[str, Any]													=		MCLIPConfig





						def __init__(       self		,__UpperCAmelCase		,*__UpperCAmelCase		,**__UpperCAmelCase     )					->				List[Any]:
													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     )					->				Tuple:
													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





