'''simple docstring'''

import copy

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


_lowerCamelCase :				List[Any]														= logging.get_logger(__name__)




class    lowerCamelCase__  (   SCREAMING_SNAKE_CASE_     ):
   __UpperCAmelCase           =						"""hybrid-clip"""
   __UpperCAmelCase           =						True



   def __init__(    self					,      lowerCAmelCase__=512					,      **lowerCAmelCase__     )				->     Dict:
        """simple docstring"""





        super().__init__(**__UpperCAmelCase     )

        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`."""     )

        _UpperCamelCase  :Union[str, Any]       =kwargs.pop("""text_config"""     )
        _UpperCamelCase  :Any       =kwargs.pop("""vision_config"""     )

        _UpperCamelCase  :str       =text_config.pop("""model_type"""     )
        _UpperCamelCase  :List[str]       =vision_config.pop("""model_type"""     )

        from transformers import AutoConfig

        _UpperCamelCase  :Optional[Any]       =AutoConfig.for_model(__UpperCAmelCase					,      **__UpperCAmelCase     )

        if vision_model_type == "clip":
             _UpperCamelCase  :List[Any]       =AutoConfig.for_model(__UpperCAmelCase					,      **__UpperCAmelCase     ).vision_config
        elif vision_model_type == "clip_vision_model":
             from transformers import CLIPVisionConfig

             _UpperCamelCase  :int       =CLIPVisionConfig(**__UpperCAmelCase     )
        else:
             _UpperCamelCase  :Union[str, Any]       =AutoConfig.for_model(__UpperCAmelCase					,      **__UpperCAmelCase     )

        _UpperCamelCase  :List[str]       =projection_dim
        _UpperCamelCase  :Any       =1.0



   @classmethod
   def  _UpperCamelCase		(    cls					,      lowerCAmelCase__					,      lowerCAmelCase__					,      **lowerCAmelCase__     )				->     Optional[int]:
        """simple docstring"""





        return cls(text_config=text_config.to_dict()					,      vision_config=vision_config.to_dict()					,      **__UpperCAmelCase     )




   def  _UpperCamelCase		(    self     )				->     str:
        """simple docstring"""





        _UpperCamelCase  :str       =copy.deepcopy(self.__dict__     )
        _UpperCamelCase  :Optional[Any]       =self.text_config.to_dict()
        _UpperCamelCase  :List[Any]       =self.vision_config.to_dict()
        _UpperCamelCase  :str       =self.__class__.model_type
        return output

"""simple docstring"""






def    UpperCamelCase						(					UpperCAmelCase ,   UpperCAmelCase = 1_000     )						->str:

   """simple docstring"""



   if (not isinstance(UpperCAmelCase ,   UpperCAmelCase     )) or (digit_position <= 0):
      raise ValueError("Digit position must be a positive integer"     )
   elif (not isinstance(UpperCAmelCase ,   UpperCAmelCase     )) or (precision < 0):
      raise ValueError("Precision must be a nonnegative integer"     )

   # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
   # accurate
   a_						   =     (
       4 * _subsum(UpperCAmelCase ,   1 ,   UpperCAmelCase     )
       - 2 * _subsum(UpperCAmelCase ,   4 ,   UpperCAmelCase     )
       - _subsum(UpperCAmelCase ,   5 ,   UpperCAmelCase     )
       - _subsum(UpperCAmelCase ,   6 ,   UpperCAmelCase     )
   )

   # return the first hex digit of the fractional part of the result
   return hex(int((sum_result % 1) * 16     )     )[2:]
def    UpperCamelCase						(					UpperCAmelCase ,   UpperCAmelCase ,   UpperCAmelCase     )						->float:

   """simple docstring"""



   a_						   =     0.0
   for sum_index in range(digit_pos_to_extract + precision     ):
      a_						   =     8 * sum_index + denominator_addend
      if sum_index < digit_pos_to_extract:
         # if the exponential term is an integer and we mod it by the denominator
         # before dividing, only the integer part of the sum will change;
         # the fractional part will not
         a_						   =     pow(
             16 ,   digit_pos_to_extract - 1 - sum_index ,   UpperCAmelCase     )
      else:
         a_						   =     pow(16 ,   digit_pos_to_extract - 1 - sum_index     )
      total += exponential_term / denominator
   return total


if __name__ == "__main__":
      import doctest

      doctest.testmod()