


import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


A							:					int     						=     logging.get_logger(__name__)

A							:					Optional[Any]     						=     {
    'Salesforce/instruct-blip-flan-t5': 'https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json',
}






class     UpperCamelCase(  lowerCAmelCase__   ):
					snake_case_		:				str										=	"instructblip_vision_model"


					def __init__(						self	:		int     ,    SCREAMING_SNAKE_CASE	:		Tuple=1_4_0_8     ,    SCREAMING_SNAKE_CASE	:		List[str]=6_1_4_4     ,    SCREAMING_SNAKE_CASE	:		int=3_9     ,    SCREAMING_SNAKE_CASE	:		List[Any]=1_6     ,    SCREAMING_SNAKE_CASE	:		List[str]=2_2_4     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=1_4     ,    SCREAMING_SNAKE_CASE	:		str="gelu"     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=1e-6     ,    SCREAMING_SNAKE_CASE	:		List[Any]=0.0     ,    SCREAMING_SNAKE_CASE	:		List[Any]=1e-1_0     ,    SCREAMING_SNAKE_CASE	:		int=True     ,    **SCREAMING_SNAKE_CASE	:		Optional[Any]     ,    )			->	Tuple:




											'''simple docstring'''

											super().__init__(**_lowerCamelCase						)

											__snake_case				=		hidden_size
											__snake_case				=		intermediate_size
											__snake_case				=		num_hidden_layers
											__snake_case				=		num_attention_heads
											__snake_case				=		patch_size
											__snake_case				=		image_size
											__snake_case				=		initializer_range
											__snake_case				=		attention_dropout
											__snake_case				=		layer_norm_eps
											__snake_case				=		hidden_act
											__snake_case				=		qkv_bias






					@classmethod
					def 							SCREAMING_SNAKE_CASE_  (						cls	:		Optional[int]     ,    SCREAMING_SNAKE_CASE	:		List[str]     ,    **SCREAMING_SNAKE_CASE	:		Optional[int]						)			->	"PretrainedConfig":




											'''simple docstring'''

											cls._set_token_in_kwargs(_lowerCamelCase						)

											__snake_case		,					__snake_case				=		cls.get_config_dict(_lowerCamelCase     ,    **_lowerCamelCase						)

											# get the vision config dict if we are loading from InstructBlipConfig
											if config_dict.get("model_type"						) == "instructblip":
																	__snake_case				=		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(_lowerCamelCase     ,    **_lowerCamelCase						)






class     UpperCamelCase(  lowerCAmelCase__   ):
					snake_case_		:				Dict										=	"instructblip_qformer"


					def __init__(						self	:		Optional[int]     ,    SCREAMING_SNAKE_CASE	:		Dict=3_0_5_2_2     ,    SCREAMING_SNAKE_CASE	:		str=7_6_8     ,    SCREAMING_SNAKE_CASE	:		Any=1_2     ,    SCREAMING_SNAKE_CASE	:		int=1_2     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=3_0_7_2     ,    SCREAMING_SNAKE_CASE	:		int="gelu"     ,    SCREAMING_SNAKE_CASE	:		int=0.1     ,    SCREAMING_SNAKE_CASE	:		List[str]=0.1     ,    SCREAMING_SNAKE_CASE	:		List[Any]=5_1_2     ,    SCREAMING_SNAKE_CASE	:		int=0.02     ,    SCREAMING_SNAKE_CASE	:		List[str]=1e-1_2     ,    SCREAMING_SNAKE_CASE	:		Any=0     ,    SCREAMING_SNAKE_CASE	:		List[Any]="absolute"     ,    SCREAMING_SNAKE_CASE	:		List[Any]=2     ,    SCREAMING_SNAKE_CASE	:		int=1_4_0_8     ,    **SCREAMING_SNAKE_CASE	:		List[Any]     ,    )			->	Union[str, Any]:




											'''simple docstring'''

											super().__init__(pad_token_id=_lowerCamelCase     ,    **_lowerCamelCase						)

											__snake_case				=		vocab_size
											__snake_case				=		hidden_size
											__snake_case				=		num_hidden_layers
											__snake_case				=		num_attention_heads
											__snake_case				=		hidden_act
											__snake_case				=		intermediate_size
											__snake_case				=		hidden_dropout_prob
											__snake_case				=		attention_probs_dropout_prob
											__snake_case				=		max_position_embeddings
											__snake_case				=		initializer_range
											__snake_case				=		layer_norm_eps
											__snake_case				=		position_embedding_type
											__snake_case				=		cross_attention_frequency
											__snake_case				=		encoder_hidden_size






					@classmethod
					def 							SCREAMING_SNAKE_CASE_  (						cls	:		Dict     ,    SCREAMING_SNAKE_CASE	:		List[Any]     ,    **SCREAMING_SNAKE_CASE	:		Any						)			->	"PretrainedConfig":




											'''simple docstring'''

											cls._set_token_in_kwargs(_lowerCamelCase						)

											__snake_case		,					__snake_case				=		cls.get_config_dict(_lowerCamelCase     ,    **_lowerCamelCase						)

											# get the qformer config dict if we are loading from InstructBlipConfig
											if config_dict.get("model_type"						) == "instructblip":
																	__snake_case				=		config_dict["qformer_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(_lowerCamelCase     ,    **_lowerCamelCase						)






class     UpperCamelCase(  lowerCAmelCase__   ):
					snake_case_		:				List[str]										=	"instructblip"
					snake_case_		:				str										=	True


					def __init__(						self	:		Union[str, Any]     ,    SCREAMING_SNAKE_CASE	:		int=None     ,    SCREAMING_SNAKE_CASE	:		Tuple=None     ,    SCREAMING_SNAKE_CASE	:		Dict=None     ,    SCREAMING_SNAKE_CASE	:		Union[str, Any]=3_2     ,    **SCREAMING_SNAKE_CASE	:		Optional[Any]						)			->	Optional[Any]:




											'''simple docstring'''

											super().__init__(**_lowerCamelCase						)

											if vision_config is None:
																	__snake_case				=		{}
																	logger.info("vision_config is None. initializing the InstructBlipVisionConfig with default values."						)

											if qformer_config is None:
																	__snake_case				=		{}
																	logger.info("qformer_config is None. Initializing the InstructBlipQFormerConfig with default values."						)

											if text_config is None:
																	__snake_case				=		{}
																	logger.info("text_config is None. Initializing the text config with default values (`OPTConfig`)."						)

											__snake_case				=		InstructBlipVisionConfig(**_lowerCamelCase						)
											__snake_case				=		InstructBlipQFormerConfig(**_lowerCamelCase						)
											__snake_case				=		text_config["model_type"] if "model_type" in text_config else "opt"
											__snake_case				=		CONFIG_MAPPING[text_model_type](**_lowerCamelCase						)

											__snake_case				=		self.text_config.tie_word_embeddings
											__snake_case				=		self.text_config.is_encoder_decoder

											__snake_case				=		num_query_tokens
											__snake_case				=		self.vision_config.hidden_size
											__snake_case				=		self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
											__snake_case				=		1.0
											__snake_case				=		0.02


					@classmethod
					def 							SCREAMING_SNAKE_CASE_  (						cls	:		List[Any]     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]     ,    SCREAMING_SNAKE_CASE	:		Any     ,    SCREAMING_SNAKE_CASE	:		Union[str, Any]     ,    **SCREAMING_SNAKE_CASE	:		int     ,    )			->	Optional[int]:




											'''simple docstring'''

											return cls(
											    vision_config=vision_config.to_dict()     ,    qformer_config=qformer_config.to_dict()     ,    text_config=text_config.to_dict()     ,    **_lowerCamelCase     ,    )






					def 							SCREAMING_SNAKE_CASE_  (						self	:		Any						)			->	Any:




											'''simple docstring'''

											__snake_case				=		copy.deepcopy(self.__dict__						)
											__snake_case				=		self.vision_config.to_dict()
											__snake_case				=		self.qformer_config.to_dict()
											__snake_case				=		self.text_config.to_dict()
											__snake_case				=		self.__class__.model_type
											return output









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


A							:					str     						=     logging.get_logger(__name__)

A							:					str     						=     {
    'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/config.json',
    'google/fnet-large': 'https://huggingface.co/google/fnet-large/resolve/main/config.json'
    # See all FNet models at https://huggingface.co/models?filter=fnet
}






class     UpperCamelCase(  _a   ):
					snake_case_		:				List[Any]										=	"""fnet"""


					def __init__(						self	:		Dict     ,    SCREAMING_SNAKE_CASE	:		Dict=3_2_0_0_0     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=7_6_8     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=1_2     ,    SCREAMING_SNAKE_CASE	:		Any=3_0_7_2     ,    SCREAMING_SNAKE_CASE	:		Tuple="gelu_new"     ,    SCREAMING_SNAKE_CASE	:		Any=0.1     ,    SCREAMING_SNAKE_CASE	:		Dict=5_1_2     ,    SCREAMING_SNAKE_CASE	:		str=4     ,    SCREAMING_SNAKE_CASE	:		Tuple=0.02     ,    SCREAMING_SNAKE_CASE	:		Optional[Any]=1e-1_2     ,    SCREAMING_SNAKE_CASE	:		Dict=False     ,    SCREAMING_SNAKE_CASE	:		int=5_1_2     ,    SCREAMING_SNAKE_CASE	:		str=3     ,    SCREAMING_SNAKE_CASE	:		str=1     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=2     ,    **SCREAMING_SNAKE_CASE	:		List[Any]     ,    )			->	List[Any]:




											'''simple docstring'''

											super().__init__(pad_token_id=SCREAMING_SNAKE_CASE     ,    bos_token_id=SCREAMING_SNAKE_CASE     ,    eos_token_id=SCREAMING_SNAKE_CASE     ,    **SCREAMING_SNAKE_CASE						)

											__snake_case				=		vocab_size
											__snake_case				=		max_position_embeddings
											__snake_case				=		hidden_size
											__snake_case				=		num_hidden_layers
											__snake_case				=		intermediate_size
											__snake_case				=		hidden_act
											__snake_case				=		hidden_dropout_prob
											__snake_case				=		initializer_range
											__snake_case				=		type_vocab_size
											__snake_case				=		layer_norm_eps
											__snake_case				=		use_tpu_fourier_optimizations
											__snake_case				=		tpu_short_seq_length





