"""simple docstring"""




import copy
import os
from typing import Union

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


__lowerCamelCase							 =     logging.get_logger(__name__)

__lowerCamelCase							 =     {
    "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 			UpperCamelCase__(	__A       ):
						lowerCAmelCase__     :  int  							=						'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.0_2						,__UpperCAmelCase=3_05_22						,__UpperCAmelCase=2						,__UpperCAmelCase=0						,__UpperCAmelCase=1_02						,__UpperCAmelCase=True						,__UpperCAmelCase=True						,**__UpperCAmelCase						,)    -> Tuple:
													super().__init__(
													    pad_token_id=__UpperCAmelCase						,bos_token_id=__UpperCAmelCase						,eos_token_id=__UpperCAmelCase						,sep_token_id=__UpperCAmelCase						,**__UpperCAmelCase						,)

													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  snake_case__		(				cls						,__UpperCAmelCase						,**__UpperCAmelCase   )    -> "PretrainedConfig":
													cls._set_token_in_kwargs(__UpperCAmelCase   )

													A__   ,     A__		   =							cls.get_config_dict(__UpperCAmelCase						,**__UpperCAmelCase   )

													# 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(__UpperCAmelCase						,**__UpperCAmelCase   )






class 			UpperCamelCase__(	__A       ):
						lowerCAmelCase__     :  str  							=						'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						,)    -> Any:
													super().__init__(**__UpperCAmelCase   )

													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  snake_case__		(				cls						,__UpperCAmelCase						,**__UpperCAmelCase   )    -> "PretrainedConfig":
													cls._set_token_in_kwargs(__UpperCAmelCase   )

													A__   ,     A__		   =							cls.get_config_dict(__UpperCAmelCase						,**__UpperCAmelCase   )

													# 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(__UpperCAmelCase						,**__UpperCAmelCase   )






class 			UpperCamelCase__(	__A       ):
						lowerCAmelCase__     :  List[Any]  							=						'blip'
						lowerCAmelCase__     :  int  							=						True





						def __init__(				self						,__UpperCAmelCase=None						,__UpperCAmelCase=None						,__UpperCAmelCase=5_12						,__UpperCAmelCase=2.6_5_9_2						,__UpperCAmelCase=2_56						,**__UpperCAmelCase						,)    -> Dict:
													super().__init__(**__UpperCAmelCase   )

													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(**__UpperCAmelCase   )
													A__		   =							BlipVisionConfig(**__UpperCAmelCase   )

													A__		   =							self.vision_config.hidden_size

													A__		   =							projection_dim
													A__		   =							logit_scale_init_value
													A__		   =							1.0
													A__		   =							0.0_2
													A__		   =							image_text_hidden_size





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





						def  snake_case__		(				self   )    -> List[str]:
													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"""




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


__lowerCamelCase							 =     logging.get_logger(__name__)

__lowerCamelCase							 =     {
    "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json",
}
class 			UpperCamelCase__(	__A       ):
						lowerCAmelCase__     :  Union[str, Any]  							=						'transfo-xl'
						lowerCAmelCase__     :  Any  							=						['mems']
						lowerCAmelCase__     :  Tuple  							=						{
						    'n_token': 'vocab_size',
						    'hidden_size': 'd_model',
						    'num_attention_heads': 'n_head',
						    'num_hidden_layers': 'n_layer',
						}





						def __init__(				self						,__UpperCAmelCase=26_77_35						,__UpperCAmelCase=[2_00_00, 4_00_00, 20_00_00]						,__UpperCAmelCase=10_24						,__UpperCAmelCase=10_24						,__UpperCAmelCase=16						,__UpperCAmelCase=64						,__UpperCAmelCase=40_96						,__UpperCAmelCase=4						,__UpperCAmelCase=False						,__UpperCAmelCase=18						,__UpperCAmelCase=16_00						,__UpperCAmelCase=10_00						,__UpperCAmelCase=True						,__UpperCAmelCase=True						,__UpperCAmelCase=0						,__UpperCAmelCase=-1						,__UpperCAmelCase=True						,__UpperCAmelCase=0.1						,__UpperCAmelCase=0.0						,__UpperCAmelCase=True						,__UpperCAmelCase="normal"						,__UpperCAmelCase=0.0_1						,__UpperCAmelCase=0.0_1						,__UpperCAmelCase=0.0_2						,__UpperCAmelCase=1e-5						,__UpperCAmelCase=0						,**__UpperCAmelCase						,)    -> Tuple:
													A__		   =							vocab_size
													A__		   =							[]
													self.cutoffs.extend(__UpperCAmelCase   )
													if proj_share_all_but_first:
																				A__		   =							[False] + [True] * len(self.cutoffs   )
													else:
																				A__		   =							[False] + [False] * len(self.cutoffs   )
													A__		   =							d_model
													A__		   =							d_embed
													A__		   =							d_head
													A__		   =							d_inner
													A__		   =							div_val
													A__		   =							pre_lnorm
													A__		   =							n_layer
													A__		   =							n_head
													A__		   =							mem_len
													A__		   =							same_length
													A__		   =							attn_type
													A__		   =							clamp_len
													A__		   =							sample_softmax
													A__		   =							adaptive
													A__		   =							dropout
													A__		   =							dropatt
													A__		   =							untie_r
													A__		   =							init
													A__		   =							init_range
													A__		   =							proj_init_std
													A__		   =							init_std
													A__		   =							layer_norm_epsilon
													super().__init__(eos_token_id=__UpperCAmelCase						,**__UpperCAmelCase   )





						@property
						def  snake_case__		(				self   )    -> Optional[Any]:
													# Message copied from Transformer-XL documentation
													logger.info(f'''The model {self.model_type} is one of the few models that has no sequence length limit.'''   )
													return -1





						@max_position_embeddings.setter
						def  snake_case__		(				self						,__UpperCAmelCase   )    -> int:
													# Message copied from Transformer-XL documentation
													raise NotImplementedError(
													    f'''The model {self.model_type} is one of the few models that has no sequence length limit.'''   )





