




"""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_				:    Optional[int]										=     {
    '''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(      lowercase__				):




					'''simple docstring'''


					__a						:						Any     		= 'blip_text_model'
					def __init__(    self						,	__a=30524						,	__a=768						,	__a=768						,	__a=3072						,	__a=768						,	__a=12						,	__a=8						,	__a=512						,	__a="gelu"						,	__a=1E-12						,	__a=0.0						,	__a=0.0						,	__a=0.02						,	__a=30522						,	__a=2						,	__a=0						,	__a=102						,	__a=True						,	__a=True						,	**__a						,	):
								super().__init__(
								    pad_token_id=__a						,	bos_token_id=__a						,	eos_token_id=__a						,	sep_token_id=__a						,	**__a						,	)

								__lowerCamelCase					:	str	       =				vocab_size
								__lowerCamelCase					:	Union[str, Any]	       =				hidden_size
								__lowerCamelCase					:	Dict	       =				encoder_hidden_size
								__lowerCamelCase					:	int	       =				intermediate_size
								__lowerCamelCase					:	List[Any]	       =				projection_dim
								__lowerCamelCase					:	Optional[Any]	       =				hidden_dropout_prob
								__lowerCamelCase					:	List[Any]	       =				num_hidden_layers
								__lowerCamelCase					:	Optional[int]	       =				num_attention_heads
								__lowerCamelCase					:	Dict	       =				max_position_embeddings
								__lowerCamelCase					:	Optional[Any]	       =				layer_norm_eps
								__lowerCamelCase					:	Any	       =				hidden_act
								__lowerCamelCase					:	str	       =				initializer_range
								__lowerCamelCase					:	Dict	       =				attention_probs_dropout_prob
								__lowerCamelCase					:	Dict	       =				is_decoder
								__lowerCamelCase					:	int	       =				use_cache





					@classmethod
					def     snake_case_				(    cls						,	__a						,	**__a     ):
								cls._set_token_in_kwargs(__a     )

								__lowerCamelCase       ,      __lowerCamelCase					:	Optional[int]	       =				cls.get_config_dict(__a						,	**__a     )

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



class __lowercase(      lowercase__				):




					'''simple docstring'''


					__a						:						List[Any]     		= 'blip_vision_model'
					def __init__(    self						,	__a=768						,	__a=3072						,	__a=512						,	__a=12						,	__a=12						,	__a=384						,	__a=16						,	__a="gelu"						,	__a=1E-5						,	__a=0.0						,	__a=1E-10						,	**__a						,	):
								super().__init__(**__a     )

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





					@classmethod
					def     snake_case_				(    cls						,	__a						,	**__a     ):
								cls._set_token_in_kwargs(__a     )

								__lowerCamelCase       ,      __lowerCamelCase					:	Dict	       =				cls.get_config_dict(__a						,	**__a     )

								# get the vision config dict if we are loading from BlipConfig
								if config_dict.get('model_type'     ) == "blip":
											__lowerCamelCase					:	Union[str, Any]	       =				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 __lowercase(      lowercase__				):




					'''simple docstring'''


					__a						:						Optional[int]     		= 'blip'
					__a						:						Optional[int]     		= True
					def __init__(    self						,	__a=None						,	__a=None						,	__a=512						,	__a=2.6_592						,	__a=256						,	**__a						,	):
								super().__init__(**__a     )

								if text_config is None:
											__lowerCamelCase					:	Union[str, Any]	       =				{}
											logger.info('`text_config` is `None`. Initializing the `BlipTextConfig` with default values.'     )

								if vision_config is None:
											__lowerCamelCase					:	Optional[int]	       =				{}
											logger.info('`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.'     )

								__lowerCamelCase					:	Union[str, Any]	       =				BlipTextConfig(**__a     )
								__lowerCamelCase					:	int	       =				BlipVisionConfig(**__a     )

								__lowerCamelCase					:	List[Any]	       =				self.vision_config.hidden_size

								__lowerCamelCase					:	List[Any]	       =				projection_dim
								__lowerCamelCase					:	Optional[int]	       =				logit_scale_init_value
								__lowerCamelCase					:	List[Any]	       =				1.0
								__lowerCamelCase					:	Union[str, Any]	       =				0.02
								__lowerCamelCase					:	Optional[Any]	       =				image_text_hidden_size
					@classmethod
					def     snake_case_				(    cls						,	__a						,	__a						,	**__a     ):
								return cls(text_config=text_config.to_dict()						,	vision_config=vision_config.to_dict()						,	**__a     )





					def     snake_case_				(    self     ):
								__lowerCamelCase					:	int	       =				copy.deepcopy(self.__dict__     )
								__lowerCamelCase					:	int	       =				self.text_config.to_dict()
								__lowerCamelCase					:	int	       =				self.vision_config.to_dict()
								__lowerCamelCase					:	List[Any]	       =				self.__class__.model_type
								return output









"""simple docstring"""
a_				:    Dict										=     {
    '''meter''': '''m''',
    '''kilometer''': '''km''',
    '''megametre''': '''Mm''',
    '''gigametre''': '''Gm''',
    '''terametre''': '''Tm''',
    '''petametre''': '''Pm''',
    '''exametre''': '''Em''',
    '''zettametre''': '''Zm''',
    '''yottametre''': '''Ym''',
}
# Exponent of the factor(meter)
a_				:    Optional[int]										=     {
    '''m''': 0,
    '''km''': 3,
    '''Mm''': 6,
    '''Gm''': 9,
    '''Tm''': 12,
    '''Pm''': 15,
    '''Em''': 18,
    '''Zm''': 21,
    '''Ym''': 24,
}





def 						UpperCAmelCase				(			A__:    float							,				A__:    str							,				A__:    str     )  ->     float:
			__lowerCamelCase					:	List[Any]	       =				from_type.lower().strip('s'     )
			__lowerCamelCase					:	Optional[int]	       =				to_type.lower().strip('s'     )

			__lowerCamelCase					:	int	       =				UNIT_SYMBOL.get(A__							,				A__     )
			__lowerCamelCase					:	Dict	       =				UNIT_SYMBOL.get(A__							,				A__     )

			if from_sanitized not in METRIC_CONVERSION:
						__lowerCamelCase					:	Dict	       =				(
						    f'''Invalid \'from_type\' value: {from_type!r}.\n'''
						    f'''Conversion abbreviations are: {", ".join(A__     )}'''
						)
						raise ValueError(A__     )
			if to_sanitized not in METRIC_CONVERSION:
						__lowerCamelCase					:	Any	       =				(
						    f'''Invalid \'to_type\' value: {to_type!r}.\n'''
						    f'''Conversion abbreviations are: {", ".join(A__     )}'''
						)
						raise ValueError(A__     )
			__lowerCamelCase					:	Any	       =				METRIC_CONVERSION[from_sanitized]
			__lowerCamelCase					:	Tuple	       =				METRIC_CONVERSION[to_sanitized]
			__lowerCamelCase					:	Any	       =				1

			if from_exponent > to_exponent:
						__lowerCamelCase					:	Union[str, Any]	       =				from_exponent - to_exponent
			else:
						__lowerCamelCase					:	List[Any]	       =				-(to_exponent - from_exponent)

			return value * pow(10							,				A__     )


if __name__ == "__main__":
					from doctest import testmod

					testmod()



