


import copy

from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging


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



class 							a       (      _UpperCAmelCase ):
     UpperCAmelCase__			:	List[Any]       =						"hybrid-clip"
     UpperCAmelCase__			:	int       =						True





     def __init__(     self       :					str     ,						SCREAMING_SNAKE_CASE_       :					int=512     ,						**SCREAMING_SNAKE_CASE_       :					Union[str, Any]				):
        super().__init__(**SCREAMING_SNAKE_CASE_				)

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

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

        __lowerCamelCase:					Tuple	 =						kwargs.pop("""text_config"""				)
        __lowerCamelCase:					Optional[Any]	 =						kwargs.pop("""vision_config"""				)

        __lowerCamelCase:					Optional[Any]	 =						text_config.pop("""model_type"""				)
        __lowerCamelCase:					List[Any]	 =						vision_config.pop("""model_type"""				)

        from transformers import AutoConfig

        __lowerCamelCase:					List[str]	 =						AutoConfig.for_model(SCREAMING_SNAKE_CASE_     ,						**SCREAMING_SNAKE_CASE_				)

        if vision_model_type == "clip":
           __lowerCamelCase:					Any	 =						AutoConfig.for_model(SCREAMING_SNAKE_CASE_     ,						**SCREAMING_SNAKE_CASE_				).vision_config
        elif vision_model_type == "clip_vision_model":
           from transformers import CLIPVisionConfig

           __lowerCamelCase:					Optional[int]	 =						CLIPVisionConfig(**SCREAMING_SNAKE_CASE_				)
        else:
           __lowerCamelCase:					str	 =						AutoConfig.for_model(SCREAMING_SNAKE_CASE_     ,						**SCREAMING_SNAKE_CASE_				)

        __lowerCamelCase:					int	 =						projection_dim
        __lowerCamelCase:					str	 =						1.0





     @classmethod
     def 			SCREAMING_SNAKE_CASE__							(     cls       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					PretrainedConfig     ,						SCREAMING_SNAKE_CASE_       :					PretrainedConfig     ,						**SCREAMING_SNAKE_CASE_       :					Optional[Any]				):
        return cls(text_config=text_config.to_dict()     ,						vision_config=vision_config.to_dict()     ,						**SCREAMING_SNAKE_CASE_				)







     def 			SCREAMING_SNAKE_CASE__							(     self       :					int				):
        __lowerCamelCase:					Any	 =						copy.deepcopy(self.__dict__				)
        __lowerCamelCase:					Union[str, Any]	 =						self.text_config.to_dict()
        __lowerCamelCase:					List[str]	 =						self.vision_config.to_dict()
        __lowerCamelCase:					Optional[Any]	 =						self.__class__.model_type
        return output






_A		:					Union[str, Any]          =							1_000



def      __lowerCAmelCase    (				snake_case						:     float			)							->				float:
   return x * x



def      __lowerCAmelCase    (				snake_case						:     Optional[int]    ,   snake_case						:     float    ,   snake_case						:     float    ,   snake_case						:     int = 4			)							->				float:
   assert callable(
       snake_case			), f'the function(object) passed should be callable your input : {function}'
   assert isinstance(snake_case    ,   (float, int)			), f'a should be float or integer your input : {a}'
   assert isinstance(function(snake_case			)    ,   (float, int)			), (
       "the function should return integer or float return type of your function, "
       f'{type(snake_case			)}'
   )
   assert isinstance(snake_case    ,   (float, int)			), f'b should be float or integer your input : {b}'
   assert (
       isinstance(snake_case    ,   snake_case			) 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[str]	 =						(b - a) / N_STEPS
   __lowerCamelCase:					Optional[Any]	 =						function(snake_case			) + function(snake_case			)

   for i in range(1    ,   snake_case			):
      __lowerCamelCase:					Dict	 =						a + h * i
      result += function(snake_case			) * (4 if i % 2 else 2)

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


if __name__ == "__main__":
   import doctest

   doctest.testmod()


