




"""simple docstring"""




import copy
import os
from typing import Union

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


a_        =       logging.get_logger(__name__)

a_        =       {
    '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_    (			snake_case		):
		UpperCamelCase							="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_				,						)						->       Dict:
					super().__init__(
					    pad_token_id=UpperCamelCase_				,						bos_token_id=UpperCamelCase_				,						eos_token_id=UpperCamelCase_				,						sep_token_id=UpperCamelCase_				,						**UpperCamelCase_				,						)

					__lowercase			:  Dict								=       vocab_size
					__lowercase			:  Optional[Any]								=       hidden_size
					__lowercase			:  List[str]								=       encoder_hidden_size
					__lowercase			:  Optional[Any]								=       intermediate_size
					__lowercase			:  str								=       projection_dim
					__lowercase			:  List[str]								=       hidden_dropout_prob
					__lowercase			:  Tuple								=       num_hidden_layers
					__lowercase			:  Optional[int]								=       num_attention_heads
					__lowercase			:  Tuple								=       max_position_embeddings
					__lowercase			:  List[str]								=       layer_norm_eps
					__lowercase			:  List[str]								=       hidden_act
					__lowercase			:  List[Any]								=       initializer_range
					__lowercase			:  str								=       attention_probs_dropout_prob
					__lowercase			:  Union[str, Any]								=       is_decoder
					__lowercase			:  Optional[Any]								=       use_cache
		@classmethod
		def 	_lowerCamelCase							(						cls				,						UpperCamelCase_				,						**UpperCamelCase_       )						->       "PretrainedConfig":
					cls._set_token_in_kwargs(UpperCamelCase_       )

					__lowercase			,__lowercase			:  List[str]								=       cls.get_config_dict(UpperCamelCase_				,						**UpperCamelCase_       )

					# get the text config dict if we are loading from BlipConfig
					if config_dict.get('''model_type'''       ) == "blip":
								__lowercase			:  Tuple								=       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_    (			snake_case		):
		UpperCamelCase							="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_				,						)						->       int:
					super().__init__(**UpperCamelCase_       )

					__lowercase			:  Dict								=       hidden_size
					__lowercase			:  Tuple								=       intermediate_size
					__lowercase			:  Any								=       projection_dim
					__lowercase			:  Tuple								=       num_hidden_layers
					__lowercase			:  List[Any]								=       num_attention_heads
					__lowercase			:  Union[str, Any]								=       patch_size
					__lowercase			:  Tuple								=       image_size
					__lowercase			:  Optional[int]								=       initializer_range
					__lowercase			:  int								=       attention_dropout
					__lowercase			:  List[Any]								=       layer_norm_eps
					__lowercase			:  List[str]								=       hidden_act
		@classmethod
		def 	_lowerCamelCase							(						cls				,						UpperCamelCase_				,						**UpperCamelCase_       )						->       "PretrainedConfig":
					cls._set_token_in_kwargs(UpperCamelCase_       )

					__lowercase			,__lowercase			:  Optional[Any]								=       cls.get_config_dict(UpperCamelCase_				,						**UpperCamelCase_       )

					# get the vision config dict if we are loading from BlipConfig
					if config_dict.get('''model_type'''       ) == "blip":
								__lowercase			:  List[str]								=       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_    (			snake_case		):
		UpperCamelCase							="blip"
		UpperCamelCase							=True
		def __init__(						self				,						UpperCamelCase_=None				,						UpperCamelCase_=None				,						UpperCamelCase_=5_12				,						UpperCamelCase_=2.6_5_9_2				,						UpperCamelCase_=2_56				,						**UpperCamelCase_				,						)						->       Optional[Any]:
					super().__init__(**UpperCamelCase_       )

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

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

					__lowercase			:  Tuple								=       BlipTextConfig(**UpperCamelCase_       )
					__lowercase			:  Optional[int]								=       BlipVisionConfig(**UpperCamelCase_       )

					__lowercase			:  str								=       self.vision_config.hidden_size

					__lowercase			:  List[str]								=       projection_dim
					__lowercase			:  Optional[Any]								=       logit_scale_init_value
					__lowercase			:  Any								=       1.0
					__lowercase			:  str								=       0.0_2
					__lowercase			:  int								=       image_text_hidden_size
		@classmethod
		def 	_lowerCamelCase							(						cls				,						UpperCamelCase_				,						UpperCamelCase_				,						**UpperCamelCase_       )						->       Optional[Any]:
					return cls(text_config=text_config.to_dict()				,						vision_config=vision_config.to_dict()				,						**UpperCamelCase_       )
		def 	_lowerCamelCase							(						self       )						->       Tuple:
					__lowercase			:  str								=       copy.deepcopy(self.__dict__       )
					__lowercase			:  Union[str, Any]								=       self.text_config.to_dict()
					__lowercase			:  Tuple								=       self.vision_config.to_dict()
					__lowercase			:  List[Any]								=       self.__class__.model_type
					return output










'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


a__					:			str          =     logging.get_logger(__name__)

a__					:			Any          =     {
    '''xlm-mlm-en-2048''': '''https://huggingface.co/xlm-mlm-en-2048/resolve/main/config.json''',
    '''xlm-mlm-ende-1024''': '''https://huggingface.co/xlm-mlm-ende-1024/resolve/main/config.json''',
    '''xlm-mlm-enfr-1024''': '''https://huggingface.co/xlm-mlm-enfr-1024/resolve/main/config.json''',
    '''xlm-mlm-enro-1024''': '''https://huggingface.co/xlm-mlm-enro-1024/resolve/main/config.json''',
    '''xlm-mlm-tlm-xnli15-1024''': '''https://huggingface.co/xlm-mlm-tlm-xnli15-1024/resolve/main/config.json''',
    '''xlm-mlm-xnli15-1024''': '''https://huggingface.co/xlm-mlm-xnli15-1024/resolve/main/config.json''',
    '''xlm-clm-enfr-1024''': '''https://huggingface.co/xlm-clm-enfr-1024/resolve/main/config.json''',
    '''xlm-clm-ende-1024''': '''https://huggingface.co/xlm-clm-ende-1024/resolve/main/config.json''',
    '''xlm-mlm-17-1280''': '''https://huggingface.co/xlm-mlm-17-1280/resolve/main/config.json''',
    '''xlm-mlm-100-1280''': '''https://huggingface.co/xlm-mlm-100-1280/resolve/main/config.json''',
}






class 				__snake_case     (					__magic_name__							):
	__lowerCAmelCase       						=  '''xlm'''
	__lowerCAmelCase       						=  {
	    '''hidden_size''': '''emb_dim''',
	    '''num_attention_heads''': '''n_heads''',
	    '''num_hidden_layers''': '''n_layers''',
	    '''n_words''': '''vocab_size''',  # For backward compatibility
	}





	def __init__(		self      ,       UpperCamelCase_=3_0145      ,       UpperCamelCase_=2048      ,       UpperCamelCase_=12      ,       UpperCamelCase_=16      ,       UpperCamelCase_=0.1      ,       UpperCamelCase_=0.1      ,       UpperCamelCase_=True      ,       UpperCamelCase_=False      ,       UpperCamelCase_=False      ,       UpperCamelCase_=False      ,       UpperCamelCase_=1      ,       UpperCamelCase_=True      ,       UpperCamelCase_=512      ,       UpperCamelCase_=2048**-0.5      ,       UpperCamelCase_=1E-1_2      ,       UpperCamelCase_=0.0_2      ,       UpperCamelCase_=0      ,       UpperCamelCase_=1      ,       UpperCamelCase_=2      ,       UpperCamelCase_=3      ,       UpperCamelCase_=5      ,       UpperCamelCase_=True      ,       UpperCamelCase_="first"      ,       UpperCamelCase_=True      ,       UpperCamelCase_=None      ,       UpperCamelCase_=True      ,       UpperCamelCase_=0.1      ,       UpperCamelCase_=5      ,       UpperCamelCase_=5      ,       UpperCamelCase_=0      ,       UpperCamelCase_=0      ,       UpperCamelCase_=2      ,       UpperCamelCase_=0      ,       **UpperCamelCase_      ,       )      ->		List[str]:
		snake_case__	       =   vocab_size
		snake_case__	       =   emb_dim
		snake_case__	       =   n_layers
		snake_case__	       =   n_heads
		snake_case__	       =   dropout
		snake_case__	       =   attention_dropout
		snake_case__	       =   gelu_activation
		snake_case__	       =   sinusoidal_embeddings
		snake_case__	       =   causal
		snake_case__	       =   asm
		snake_case__	       =   n_langs
		snake_case__	       =   use_lang_emb
		snake_case__	       =   layer_norm_eps
		snake_case__	       =   bos_index
		snake_case__	       =   eos_index
		snake_case__	       =   pad_index
		snake_case__	       =   unk_index
		snake_case__	       =   mask_index
		snake_case__	       =   is_encoder
		snake_case__	       =   max_position_embeddings
		snake_case__	       =   embed_init_std
		snake_case__	       =   init_std
		snake_case__	       =   summary_type
		snake_case__	       =   summary_use_proj
		snake_case__	       =   summary_activation
		snake_case__	       =   summary_proj_to_labels
		snake_case__	       =   summary_first_dropout
		snake_case__	       =   start_n_top
		snake_case__	       =   end_n_top
		snake_case__	       =   mask_token_id
		snake_case__	       =   lang_id

		if "n_words" in kwargs:
			snake_case__	       =   kwargs['n_words']

		super().__init__(pad_token_id=UpperCamelCase_      ,       bos_token_id=UpperCamelCase_      ,       **UpperCamelCase_		)






class 				__snake_case     (					__magic_name__							):





	@property
	def   _snake_case   (		self		)      ->		Mapping[str, Mapping[int, str]]:
		if self.task == "multiple-choice":
			snake_case__	       =   {0: 'batch', 1: 'choice', 2: 'sequence'}
		else:
			snake_case__	       =   {0: 'batch', 1: 'sequence'}
		return OrderedDict(
		    [
		        ('input_ids', dynamic_axis),
		        ('attention_mask', dynamic_axis),
		        ('token_type_ids', dynamic_axis),
		    ]		)



