
"""simple docstring"""




import copy
import os
from typing import Union

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


A__      :	Optional[Any]          =    logging.get_logger(__name__)

A__      :	Dict          =    {
    """Salesforce/blip-vqa-base""": """https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json""",
    """Salesforce/blip-vqa-capfit-large""": (
        """https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-base""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-large""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json"""
    ),
    """Salesforce/blip-itm-base-coco""": """https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-large-coco""": """https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-base-flikr""": """https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json""",
    """Salesforce/blip-itm-large-flikr""": (
        """https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json"""
    ),
}







class   _lowercase						(       lowerCAmelCase_				):


     '''simple docstring'''





     _A								=							'blip_text_model'



     def __init__(      self ,			__UpperCamelCase=3_05_24 ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=30_72 ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=12 ,			__UpperCamelCase=8 ,			__UpperCamelCase=5_12 ,			__UpperCamelCase="gelu" ,			__UpperCamelCase=1E-12 ,			__UpperCamelCase=0.0 ,			__UpperCamelCase=0.0 ,			__UpperCamelCase=0.02 ,			__UpperCamelCase=3_05_22 ,			__UpperCamelCase=2 ,			__UpperCamelCase=0 ,			__UpperCamelCase=1_02 ,			__UpperCamelCase=True ,			__UpperCamelCase=True ,			**__UpperCamelCase ,			)->					Union[str, Any]:
          super().__init__(
              pad_token_id=__UpperCamelCase ,			bos_token_id=__UpperCamelCase ,			eos_token_id=__UpperCamelCase ,			sep_token_id=__UpperCamelCase ,			**__UpperCamelCase ,			)

          UpperCAmelCase__							: Tuple 							=						vocab_size
          UpperCAmelCase__							: Any 							=						hidden_size
          UpperCAmelCase__							: List[str] 							=						encoder_hidden_size
          UpperCAmelCase__							: List[Any] 							=						intermediate_size
          UpperCAmelCase__							: Tuple 							=						projection_dim
          UpperCAmelCase__							: List[Any] 							=						hidden_dropout_prob
          UpperCAmelCase__							: List[Any] 							=						num_hidden_layers
          UpperCAmelCase__							: List[Any] 							=						num_attention_heads
          UpperCAmelCase__							: Any 							=						max_position_embeddings
          UpperCAmelCase__							: Any 							=						layer_norm_eps
          UpperCAmelCase__							: List[Any] 							=						hidden_act
          UpperCAmelCase__							: Any 							=						initializer_range
          UpperCAmelCase__							: Tuple 							=						attention_probs_dropout_prob
          UpperCAmelCase__							: Tuple 							=						is_decoder
          UpperCAmelCase__							: str 							=						use_cache



     @classmethod
     def  lowerCAmelCase__       (      cls ,			__UpperCamelCase ,			**__UpperCamelCase  )->					"PretrainedConfig":
          cls._set_token_in_kwargs(__UpperCamelCase  )

          UpperCAmelCase__							: Optional[Any] 							=						cls.get_config_dict(__UpperCamelCase ,			**__UpperCamelCase  )

          # get the text config dict if we are loading from BlipConfig
          if config_dict.get("model_type"  ) == "blip":
               UpperCAmelCase__							: Optional[Any] 							=						config_dict["text_config"]

          if "model_type" in config_dict and hasattr(cls ,			"model_type"  ) and config_dict["model_type"] != cls.model_type:
               logger.warning(
                   F"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
                   F"{cls.model_type}. This is not supported for all configurations of models and can yield errors."  )

          return cls.from_dict(__UpperCamelCase ,			**__UpperCamelCase  )







class   _lowercase						(       lowerCAmelCase_				):


     '''simple docstring'''





     _A								=							'blip_vision_model'



     def __init__(      self ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=30_72 ,			__UpperCamelCase=5_12 ,			__UpperCamelCase=12 ,			__UpperCamelCase=12 ,			__UpperCamelCase=3_84 ,			__UpperCamelCase=16 ,			__UpperCamelCase="gelu" ,			__UpperCamelCase=1E-5 ,			__UpperCamelCase=0.0 ,			__UpperCamelCase=1E-10 ,			**__UpperCamelCase ,			)->					List[str]:
          super().__init__(**__UpperCamelCase  )

          UpperCAmelCase__							: Optional[Any] 							=						hidden_size
          UpperCAmelCase__							: Optional[Any] 							=						intermediate_size
          UpperCAmelCase__							: Optional[Any] 							=						projection_dim
          UpperCAmelCase__							: Any 							=						num_hidden_layers
          UpperCAmelCase__							: List[Any] 							=						num_attention_heads
          UpperCAmelCase__							: List[Any] 							=						patch_size
          UpperCAmelCase__							: List[Any] 							=						image_size
          UpperCAmelCase__							: int 							=						initializer_range
          UpperCAmelCase__							: Optional[int] 							=						attention_dropout
          UpperCAmelCase__							: Any 							=						layer_norm_eps
          UpperCAmelCase__							: List[str] 							=						hidden_act



     @classmethod
     def  lowerCAmelCase__       (      cls ,			__UpperCamelCase ,			**__UpperCamelCase  )->					"PretrainedConfig":
          cls._set_token_in_kwargs(__UpperCamelCase  )

          UpperCAmelCase__							: Tuple 							=						cls.get_config_dict(__UpperCamelCase ,			**__UpperCamelCase  )

          # get the vision config dict if we are loading from BlipConfig
          if config_dict.get("model_type"  ) == "blip":
               UpperCAmelCase__							: Dict 							=						config_dict["vision_config"]

          if "model_type" in config_dict and hasattr(cls ,			"model_type"  ) and config_dict["model_type"] != cls.model_type:
               logger.warning(
                   F"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
                   F"{cls.model_type}. This is not supported for all configurations of models and can yield errors."  )

          return cls.from_dict(__UpperCamelCase ,			**__UpperCamelCase  )







class   _lowercase						(       lowerCAmelCase_				):


     '''simple docstring'''





     _A								=							'blip'
     _A								=							True



     def __init__(      self ,			__UpperCamelCase=None ,			__UpperCamelCase=None ,			__UpperCamelCase=5_12 ,			__UpperCamelCase=2.6592 ,			__UpperCamelCase=2_56 ,			**__UpperCamelCase ,			)->					Optional[Any]:
          super().__init__(**__UpperCamelCase  )

          if text_config is None:
               UpperCAmelCase__							: Dict 							=						{}
               logger.info("`text_config` is `None`. Initializing the `BlipTextConfig` with default values."  )

          if vision_config is None:
               UpperCAmelCase__							: Tuple 							=						{}
               logger.info("`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values."  )

          UpperCAmelCase__							: Dict 							=						BlipTextConfig(**__UpperCamelCase  )
          UpperCAmelCase__							: Optional[Any] 							=						BlipVisionConfig(**__UpperCamelCase  )

          UpperCAmelCase__							: Tuple 							=						self.vision_config.hidden_size

          UpperCAmelCase__							: Optional[int] 							=						projection_dim
          UpperCAmelCase__							: List[Any] 							=						logit_scale_init_value
          UpperCAmelCase__							: Tuple 							=						1.0
          UpperCAmelCase__							: List[Any] 							=						0.02
          UpperCAmelCase__							: List[Any] 							=						image_text_hidden_size



     @classmethod
     def  lowerCAmelCase__       (      cls ,			__UpperCamelCase ,			__UpperCamelCase ,			**__UpperCamelCase  )->					Optional[int]:
          return cls(text_config=text_config.to_dict() ,			vision_config=vision_config.to_dict() ,			**__UpperCamelCase  )



     def  lowerCAmelCase__       (      self  )->					Union[str, Any]:
          UpperCAmelCase__							: str 							=						copy.deepcopy(self.__dict__  )
          UpperCAmelCase__							: Optional[Any] 							=						self.text_config.to_dict()
          UpperCAmelCase__							: Any 							=						self.vision_config.to_dict()
          UpperCAmelCase__							: Optional[int] 							=						self.__class__.model_type
          return output





"""simple docstring"""




def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''
     if a < 0:
          raise ValueError("Input value must be a positive integer"		)
     elif isinstance(lowerCAmelCase       ,    lowerCAmelCase		):
          raise TypeError("Input value must be a 'int' type"		)
     return bin(lowerCAmelCase		).count("1"		)


if __name__ == "__main__":
    import doctest

    doctest.testmod()



