





'''simple docstring'''







import copy
import os
from typing import Union

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


lowerCAmelCase_					:    str      	=			logging.get_logger(__name__)

lowerCAmelCase_					:    Tuple      	=			{
    '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 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='blip_text_model'




				def __init__(  self     :					int					,				__a     :					int=3_05_24					,				__a     :					List[Any]=7_68					,				__a     :					Dict=7_68					,				__a     :					List[str]=30_72					,				__a     :					Any=7_68					,				__a     :					Optional[Any]=12					,				__a     :					Optional[int]=8					,				__a     :					Any=5_12					,				__a     :					Tuple="gelu"					,				__a     :					Any=1e-1_2					,				__a     :					Optional[Any]=0.0					,				__a     :					int=0.0					,				__a     :					Dict=0.02					,				__a     :					Optional[int]=3_05_22					,				__a     :					Union[str, Any]=2					,				__a     :					Tuple=0					,				__a     :					Tuple=1_02					,				__a     :					Union[str, Any]=True					,				__a     :					Any=True					,				**__a     :					List[str]					,				):
								super().__init__(
								    pad_token_id=__a					,				bos_token_id=__a					,				eos_token_id=__a					,				sep_token_id=__a					,				**__a					,				)

								_a								= vocab_size
								_a								= hidden_size
								_a								= encoder_hidden_size
								_a								= intermediate_size
								_a								= projection_dim
								_a								= hidden_dropout_prob
								_a								= num_hidden_layers
								_a								= num_attention_heads
								_a								= max_position_embeddings
								_a								= layer_norm_eps
								_a								= hidden_act
								_a								= initializer_range
								_a								= attention_probs_dropout_prob
								_a								= is_decoder
								_a								= use_cache




				@classmethod
				def   UpperCamelCase__   (  cls     :					Tuple					,				__a     :					Union[str, os.PathLike]					,				**__a     :					Any					):
								cls._set_token_in_kwargs(__a					)

								_a	,					_a								= cls.get_config_dict(__a					,				**__a					)

								# get the text config dict if we are loading from BlipConfig
								if config_dict.get("model_type"					) == "blip":
												_a								= 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(__a					,				**__a					)


class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='blip_vision_model'




				def __init__(  self     :					Optional[int]					,				__a     :					Any=7_68					,				__a     :					Optional[Any]=30_72					,				__a     :					Optional[Any]=5_12					,				__a     :					Tuple=12					,				__a     :					List[Any]=12					,				__a     :					str=3_84					,				__a     :					Dict=16					,				__a     :					str="gelu"					,				__a     :					Optional[Any]=1e-5					,				__a     :					Dict=0.0					,				__a     :					Dict=1e-1_0					,				**__a     :					Dict					,				):
								super().__init__(**__a					)

								_a								= hidden_size
								_a								= intermediate_size
								_a								= projection_dim
								_a								= num_hidden_layers
								_a								= num_attention_heads
								_a								= patch_size
								_a								= image_size
								_a								= initializer_range
								_a								= attention_dropout
								_a								= layer_norm_eps
								_a								= hidden_act




				@classmethod
				def   UpperCamelCase__   (  cls     :					str					,				__a     :					Union[str, os.PathLike]					,				**__a     :					str					):
								cls._set_token_in_kwargs(__a					)

								_a	,					_a								= cls.get_config_dict(__a					,				**__a					)

								# get the vision config dict if we are loading from BlipConfig
								if config_dict.get("model_type"					) == "blip":
												_a								= 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(__a					,				**__a					)


class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='blip'
				__a            =True




				def __init__(  self     :					Union[str, Any]					,				__a     :					Optional[int]=None					,				__a     :					str=None					,				__a     :					int=5_12					,				__a     :					int=2.6592					,				__a     :					Any=2_56					,				**__a     :					str					,				):
								super().__init__(**__a					)

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

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

								_a								= BlipTextConfig(**__a					)
								_a								= BlipVisionConfig(**__a					)

								_a								= self.vision_config.hidden_size

								_a								= projection_dim
								_a								= logit_scale_init_value
								_a								= 1.0
								_a								= 0.02
								_a								= image_text_hidden_size




				@classmethod
				def   UpperCamelCase__   (  cls     :					Tuple					,				__a     :					BlipTextConfig					,				__a     :					BlipVisionConfig					,				**__a     :					Optional[int]					):
								return cls(text_config=text_config.to_dict()					,				vision_config=vision_config.to_dict()					,				**__a					)




				def   UpperCamelCase__   (  self     :					Union[str, Any]					):
								_a								= copy.deepcopy(self.__dict__					)
								_a								= self.text_config.to_dict()
								_a								= self.vision_config.to_dict()
								_a								= self.__class__.model_type
								return output







'''simple docstring'''







def  _lowerCamelCase				( lowercase						:      int						)	->	bool:
				if num < 0:
								return False

				_a								= num
				_a								= 0
				while num > 0:
								_a								= rev_num * 10 + (num % 10)
								num //= 10

				return num_copy == rev_num


if __name__ == "__main__":
					import doctest

					doctest.testmod()
