





UpperCAmelCase_       : Union[str, Any]							=    10_00






def 				_lowerCAmelCase			(	_a :       float      )						->      float:
     return x * x






def 				_lowerCAmelCase			(	_a :       Union[str, Any]       , _a :       float       , _a :       float       , _a :       int = 4      )						->      float:
     assert callable(
         _a      ), F'the function(object) passed should be callable your input : {function}'
     assert isinstance(_a       , (float, int)      ), F'a should be float or integer your input : {a}'
     assert isinstance(function(_a      )       , (float, int)      ), (
         "the function should return integer or float return type of your function, "
         F'{type(_a      )}'
     )
     assert isinstance(_a       , (float, int)      ), F'b should be float or integer your input : {b}'
     assert (
         isinstance(_a       , _a      ) and precision > 0
     ), F'precision should be positive integer your input : {precision}'

     # just applying the formula of simpson for approximate integration written in
     # mentioned article in first comment of this file and above this function

     lowerCAmelCase_       :							List[Any]			 =		(b - a) / N_STEPS
     lowerCAmelCase_       :							Tuple			 =		function(_a      ) + function(_a      )

     for i in range(1       , _a      ):
          lowerCAmelCase_       :							int			 =		a + h * i
          result += function(_a      ) * (4 if i % 2 else 2)

     result *= h / 3
     return round(_a       , _a      )


if __name__ == "__main__":
      import doctest

      doctest.testmod()







import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


UpperCAmelCase_       : Union[str, Any]							=    logging.get_logger(__name__)





class   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""vision-text-dual-encoder"""
  __UpperCamelCase						  =	True







  def __init__(						self     ,    _lowercase=512     ,    _lowercase=2.6592     ,    **_lowercase    ):
       super().__init__(**_lowercase    )

       if "vision_config" not in kwargs:
            raise ValueError("""`vision_config` can not be `None`."""    )

       if "text_config" not in kwargs:
            raise ValueError("""`text_config` can not be `None`."""    )

       lowerCAmelCase_       :							Dict			 =		kwargs.pop("""vision_config"""    )
       lowerCAmelCase_       :							Optional[int]			 =		kwargs.pop("""text_config"""    )

       lowerCAmelCase_       :							Tuple			 =		vision_config.pop("""model_type"""    )
       lowerCAmelCase_       :							str			 =		text_config.pop("""model_type"""    )

       if vision_model_type == "clip":
            lowerCAmelCase_       :							Dict			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    ).vision_config
       elif vision_model_type == "clip_vision_model":
            lowerCAmelCase_       :							Any			 =		CLIPVisionConfig(**_lowercase    )
       else:
            lowerCAmelCase_       :							Tuple			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							List[Any]			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							Union[str, Any]			 =		projection_dim
       lowerCAmelCase_       :							Optional[int]			 =		logit_scale_init_value







  @classmethod
  def 						UpperCAmelCase__		(						cls     ,    _lowercase     ,    _lowercase     ,    **_lowercase    ):
       return cls(vision_config=vision_config.to_dict()     ,    text_config=text_config.to_dict()     ,    **_lowercase    )







  def 						UpperCAmelCase__		(						self    ):
       lowerCAmelCase_       :							int			 =		copy.deepcopy(self.__dict__    )
       lowerCAmelCase_       :							List[str]			 =		self.vision_config.to_dict()
       lowerCAmelCase_       :							List[str]			 =		self.text_config.to_dict()
       lowerCAmelCase_       :							str			 =		self.__class__.model_type
       return output
