






"""simple docstring"""
from __future__ import annotations

from itertools import permutations
from random import randint
from timeit import repeat

def 				snake_case      (   ):
			UpperCAmelCase_     : Union[str, Any]			     =					[randint(-10_00	,10_00						) for i in range(10						)]
			UpperCAmelCase_     : Optional[Any]			     =					randint(-50_00	,50_00						)
			return (arr, r)


lowerCamelCase_					=      make_dataset()

def 				snake_case      (   A__	,A__						):



			for triplet in permutations(A__	,3						):
						if sum(A__						) == target:
									return tuple(sorted(A__						)						)
			return (0, 0, 0)

def 				snake_case      (   A__	,A__						):
			arr.sort()
			UpperCAmelCase_     : int			     =					len(A__						)
			for i in range(n - 1						):
						UpperCAmelCase_     : Dict			     =					i + 1, n - 1
						while left < right:
									if arr[i] + arr[left] + arr[right] == target:
												return (arr[i], arr[left], arr[right])
									elif arr[i] + arr[left] + arr[right] < target:
												left += 1
									elif arr[i] + arr[left] + arr[right] > target:
												right -= 1
			return (0, 0, 0)

def 				snake_case      (   ):
			UpperCAmelCase_     : Any			     =					"\nfrom __main__ import dataset, triplet_sum1, triplet_sum2\n"
			UpperCAmelCase_     : str			     =					"\ntriplet_sum1(*dataset)\n"
			UpperCAmelCase_     : str			     =					"\ntriplet_sum2(*dataset)\n"
			UpperCAmelCase_     : Optional[int]			     =					repeat(setup=A__	,stmt=A__	,repeat=5	,number=1_00_00						)
			UpperCAmelCase_     : List[Any]			     =					repeat(setup=A__	,stmt=A__	,repeat=5	,number=1_00_00						)
			return (min(A__						), min(A__						))


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

			testmod()
			lowerCamelCase_					=      solution_times()
			print(f'The time for naive implementation is {times[0]}.')
			print(f'The time for optimized implementation is {times[1]}.')










import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel







class 				__lowerCAmelCase       (    UpperCamelCase__):
      _lowercase				:					Tuple						=			"""M-CLIP"""







      def __init__(    self		,      lowerCAmelCase__=1_0_2_4		,      lowerCAmelCase__=7_6_8		,      **lowerCAmelCase__							)   ->						Any:



        '''simple docstring'''




        a__	:					int										=transformerDimSize
        a__	:					Dict										=imageDimSize
        super().__init__(**lowerCAmelCase__							)







class 				__lowerCAmelCase       (    UpperCamelCase__):
      _lowercase				:					Optional[Any]						=			MCLIPConfig







      def __init__(    self		,      lowerCAmelCase__		,      *lowerCAmelCase__		,      **lowerCAmelCase__							)   ->						List[str]:



        '''simple docstring'''




        super().__init__(lowerCAmelCase__		,      *lowerCAmelCase__		,      **lowerCAmelCase__							)
        a__	:					Tuple										=XLMRobertaModel(lowerCAmelCase__							)
        a__	:					List[str]										=torch.nn.Linear(
            in_features=config.transformerDimensions		,      out_features=config.numDims							)







      def    _lowercase  (    self		,      lowerCAmelCase__		,      lowerCAmelCase__							)   ->						Union[str, Any]:



        '''simple docstring'''




        a__	:					Optional[Any]										=self.transformer(input_ids=lowerCAmelCase__		,      attention_mask=lowerCAmelCase__							)[0]
        a__	:					int										=(embs * attention_mask.unsqueeze(2							)).sum(dim=1							) / attention_mask.sum(dim=1							)[:, None]
        return self.LinearTransformation(lowerCAmelCase__							), embs






