
import copy
import os
from typing import Union

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


UpperCAmelCase       =					logging.get_logger(__name__)

UpperCAmelCase       =					{
    '''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 			A_  (     __lowerCamelCase  ):




	'''simple docstring'''


	_UpperCamelCase	:	List[str]									=			"""blip_text_model"""





	def __init__(			self						,       snake_case=3_0524						,       snake_case=768						,       snake_case=768						,       snake_case=3072						,       snake_case=768						,       snake_case=12						,       snake_case=8						,       snake_case=512						,       snake_case="gelu"						,       snake_case=1E-12						,       snake_case=0.0						,       snake_case=0.0						,       snake_case=0.02						,       snake_case=3_0522						,       snake_case=2						,       snake_case=0						,       snake_case=102						,       snake_case=True						,       snake_case=True						,       **snake_case						,       ):
		super().__init__(
		    pad_token_id=snake_case						,       bos_token_id=snake_case						,       eos_token_id=snake_case						,       sep_token_id=snake_case						,       **snake_case						,       )

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





	@classmethod
	def       SCREAMING_SNAKE_CASE__		(			cls						,       snake_case						,       **snake_case			):
		cls._set_token_in_kwargs(snake_case			)

		lowercase    ,   lowercase	    =       cls.get_config_dict(snake_case						,       **snake_case			)

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







class 			A_  (     __lowerCamelCase  ):




	'''simple docstring'''


	_UpperCamelCase	:	Tuple									=			"""blip_vision_model"""





	def __init__(			self						,       snake_case=768						,       snake_case=3072						,       snake_case=512						,       snake_case=12						,       snake_case=12						,       snake_case=384						,       snake_case=16						,       snake_case="gelu"						,       snake_case=1E-5						,       snake_case=0.0						,       snake_case=1E-10						,       **snake_case						,       ):
		super().__init__(**snake_case			)

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





	@classmethod
	def       SCREAMING_SNAKE_CASE__		(			cls						,       snake_case						,       **snake_case			):
		cls._set_token_in_kwargs(snake_case			)

		lowercase    ,   lowercase	    =       cls.get_config_dict(snake_case						,       **snake_case			)

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







class 			A_  (     __lowerCamelCase  ):




	'''simple docstring'''


	_UpperCamelCase	:	Optional[int]									=			"""blip"""
	_UpperCamelCase	:	Tuple									=			True





	def __init__(			self						,       snake_case=None						,       snake_case=None						,       snake_case=512						,       snake_case=2.6_592						,       snake_case=256						,       **snake_case						,       ):
		super().__init__(**snake_case			)

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

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

		lowercase	    =       BlipTextConfig(**snake_case			)
		lowercase	    =       BlipVisionConfig(**snake_case			)

		lowercase	    =       self.vision_config.hidden_size

		lowercase	    =       projection_dim
		lowercase	    =       logit_scale_init_value
		lowercase	    =       1.0
		lowercase	    =       0.02
		lowercase	    =       image_text_hidden_size





	@classmethod
	def       SCREAMING_SNAKE_CASE__		(			cls						,       snake_case						,       snake_case						,       **snake_case			):
		return cls(text_config=text_config.to_dict()						,       vision_config=vision_config.to_dict()						,       **snake_case			)





	def       SCREAMING_SNAKE_CASE__		(			self			):
		lowercase	    =       copy.deepcopy(self.__dict__			)
		lowercase	    =       self.text_config.to_dict()
		lowercase	    =       self.vision_config.to_dict()
		lowercase	    =       self.__class__.model_type
		return output




'''simple docstring'''





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


UpperCamelCase_    						=       logging.get_logger(__name__)

UpperCamelCase_    						=       {
    """facebook/s2t-wav2vec2-large-en-de""": (
        """https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"""
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}





class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):
				lowerCamelCase_		       =    'speech_to_text_2'
				lowerCamelCase_		       =    ['past_key_values']
				lowerCamelCase_		       =    {'num_attention_heads': 'decoder_attention_heads', 'hidden_size': 'd_model'}







				def __init__(       self     :		int		,					UpperCAmelCase__     :		Dict=10000		,					UpperCAmelCase__     :		Optional[int]=6		,					UpperCAmelCase__     :		str=2048		,					UpperCAmelCase__     :		Optional[Any]=4		,					UpperCAmelCase__     :		Union[str, Any]=0.0		,					UpperCAmelCase__     :		Optional[Any]=True		,					UpperCAmelCase__     :		Optional[Any]="relu"		,					UpperCAmelCase__     :		List[str]=256		,					UpperCAmelCase__     :		Union[str, Any]=0.1		,					UpperCAmelCase__     :		List[Any]=0.0		,					UpperCAmelCase__     :		Optional[Any]=0.0		,					UpperCAmelCase__     :		Tuple=0.02		,					UpperCAmelCase__     :		int=2		,					UpperCAmelCase__     :		str=True		,					UpperCAmelCase__     :		str=1		,					UpperCAmelCase__     :		Optional[Any]=0		,					UpperCAmelCase__     :		Optional[int]=2		,					UpperCAmelCase__     :		List[Any]=1024		,					**UpperCAmelCase__     :		Dict		,					):
										'''simple docstring'''
										lowercase :							List[str]    		=vocab_size
										lowercase :							Optional[int]    		=d_model
										lowercase :							Optional[Any]    		=decoder_ffn_dim
										lowercase :							Any    		=decoder_layers
										lowercase :							Dict    		=decoder_attention_heads
										lowercase :							List[Any]    		=dropout
										lowercase :							List[Any]    		=attention_dropout
										lowercase :							Any    		=activation_dropout
										lowercase :							Optional[Any]    		=activation_function
										lowercase :							Optional[int]    		=init_std
										lowercase :							Dict    		=decoder_layerdrop
										lowercase :							Optional[int]    		=use_cache
										lowercase :							Optional[Any]    		=decoder_layers
										lowercase :							List[str]    		=scale_embedding  # scale factor will be sqrt(d_model) if True
										lowercase :							str    		=max_target_positions

										super().__init__(
										    pad_token_id=UpperCAmelCase__		,					bos_token_id=UpperCAmelCase__		,					eos_token_id=UpperCAmelCase__		,					decoder_start_token_id=UpperCAmelCase__		,					**UpperCAmelCase__		,					)





