
"""simple docstring"""







import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel







class 							__magic_name__     (		UpperCAmelCase__   ):
     _SCREAMING_SNAKE_CASE       :					Optional[Any]     							=   'M-CLIP'





     def __init__(				self   :							Tuple							,						snake_case_   :							Tuple=1024							,						snake_case_   :							int=768							,						**snake_case_   :							List[Any]    ):
            __snake_case     			=       transformerDimSize
            __snake_case     			=       imageDimSize
            super().__init__(**__lowerCAmelCase    )







class 							__magic_name__     (		UpperCAmelCase__   ):
     _SCREAMING_SNAKE_CASE       :					Union[str, Any]     							=   MCLIPConfig





     def __init__(				self   :							Optional[Any]							,						snake_case_   :							int							,						*snake_case_   :							List[Any]							,						**snake_case_   :							str    ):
            super().__init__(__lowerCAmelCase							,						*__lowerCAmelCase							,						**__lowerCAmelCase    )
            __snake_case     			=       XLMRobertaModel(__lowerCAmelCase    )
            __snake_case     			=       torch.nn.Linear(
                in_features=config.transformerDimensions							,						out_features=config.numDims    )





     def 							lowerCAmelCase      (				self   :							List[str]							,						snake_case_   :							List[str]							,						snake_case_   :							Any    ):
            __snake_case     			=       self.transformer(input_ids=__lowerCAmelCase							,						attention_mask=__lowerCAmelCase    )[0]
            __snake_case     			=       (embs * attention_mask.unsqueeze(2    )).sum(dim=1    ) / attention_mask.sum(dim=1    )[:, None]
            return self.LinearTransformation(__lowerCAmelCase    ), embs


"""simple docstring"""







from __future__ import annotations

from collections.abc import Callable
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE							,    SCREAMING_SNAKE_CASE = 1_00							,    )  ->     float:







							"""simple docstring"""


							__snake_case     			=       x_start
							__snake_case     			=       fnc(SCREAMING_SNAKE_CASE )
							__snake_case     			=       0.0
							for _ in range(SCREAMING_SNAKE_CASE ):
														# Approximates small segments of curve as linear and solve
														# for trapezoidal area
														__snake_case     			=       (x_end - x_start) / steps + xa
														__snake_case     			=       fnc(SCREAMING_SNAKE_CASE )
														area += abs(fxa + fxa ) * (xa - xa) / 2
														# Increment step
														__snake_case     			=       xa
														__snake_case     			=       fxa
							return area


if __name__ == "__main__":
		def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE )  ->     List[Any]:







									"""simple docstring"""


									return x**3 + x**2

		print("""f(x) = x^3 + x^2""")
		print("""The area between the curve, x = -5, x = 5 and the x axis is:""")
		_SCREAMING_SNAKE_CASE	       =      10
		while i <= 100_000:
				print(F"""with {i} steps: {trapezoidal_area(f, -5, 5, i)}""")
				i *= 10
