


"""simple docstring"""







import copy
import os
from typing import Union

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


a__       :							Any        =  logging.get_logger(__name__)

a__       :							Dict        =  {
    '''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_			(				UpperCamelCase):

	"""simple docstring"""





	snake_case__       :						Optional[Any]					      =    "blip_text_model"




	def __init__(				self    :       List[str]    ,    UpperCAmelCase__    :       List[Any]=3_0_5_2_4    ,    UpperCAmelCase__    :       Dict=7_6_8    ,    UpperCAmelCase__    :       Optional[int]=7_6_8    ,    UpperCAmelCase__    :       List[Any]=3_0_7_2    ,    UpperCAmelCase__    :       str=7_6_8    ,    UpperCAmelCase__    :       List[Any]=1_2    ,    UpperCAmelCase__    :       Dict=8    ,    UpperCAmelCase__    :       Optional[int]=5_1_2    ,    UpperCAmelCase__    :       Any="gelu"    ,    UpperCAmelCase__    :       str=1E-12    ,    UpperCAmelCase__    :       List[Any]=0.0    ,    UpperCAmelCase__    :       Tuple=0.0    ,    UpperCAmelCase__    :       List[str]=0.02    ,    UpperCAmelCase__    :       Dict=3_0_5_2_2    ,    UpperCAmelCase__    :       str=2    ,    UpperCAmelCase__    :       Dict=0    ,    UpperCAmelCase__    :       Any=1_0_2    ,    UpperCAmelCase__    :       Union[str, Any]=True    ,    UpperCAmelCase__    :       Tuple=True    ,    **UpperCAmelCase__    :       Dict    ,    ) ->			Any:
						super().__init__(
						    pad_token_id=UpperCAmelCase__    ,    bos_token_id=UpperCAmelCase__    ,    eos_token_id=UpperCAmelCase__    ,    sep_token_id=UpperCAmelCase__    ,    **UpperCAmelCase__    ,    )

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




	@classmethod
	def 						UpperCAmelCase_   (				cls    :       List[str]    ,    UpperCAmelCase__    :       Union[str, os.PathLike]    ,    **UpperCAmelCase__    :       Optional[int]     ) ->			"PretrainedConfig":
						cls._set_token_in_kwargs(UpperCAmelCase__     )

						__SCREAMING_SNAKE_CASE     ,						__SCREAMING_SNAKE_CASE		     =       cls.get_config_dict(UpperCAmelCase__    ,    **UpperCAmelCase__     )

						# get the text config dict if we are loading from BlipConfig
						if config_dict.get("model_type"     ) == "blip":
											__SCREAMING_SNAKE_CASE		     =       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_			(				UpperCamelCase):

	"""simple docstring"""





	snake_case__       :						int					      =    "blip_vision_model"




	def __init__(				self    :       List[str]    ,    UpperCAmelCase__    :       Optional[int]=7_6_8    ,    UpperCAmelCase__    :       str=3_0_7_2    ,    UpperCAmelCase__    :       Optional[Any]=5_1_2    ,    UpperCAmelCase__    :       List[Any]=1_2    ,    UpperCAmelCase__    :       Optional[int]=1_2    ,    UpperCAmelCase__    :       List[Any]=3_8_4    ,    UpperCAmelCase__    :       Dict=1_6    ,    UpperCAmelCase__    :       Dict="gelu"    ,    UpperCAmelCase__    :       List[str]=1E-5    ,    UpperCAmelCase__    :       List[str]=0.0    ,    UpperCAmelCase__    :       Tuple=1E-10    ,    **UpperCAmelCase__    :       str    ,    ) ->			int:
						super().__init__(**UpperCAmelCase__     )

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




	@classmethod
	def 						UpperCAmelCase_   (				cls    :       List[Any]    ,    UpperCAmelCase__    :       Union[str, os.PathLike]    ,    **UpperCAmelCase__    :       Any     ) ->			"PretrainedConfig":
						cls._set_token_in_kwargs(UpperCAmelCase__     )

						__SCREAMING_SNAKE_CASE     ,						__SCREAMING_SNAKE_CASE		     =       cls.get_config_dict(UpperCAmelCase__    ,    **UpperCAmelCase__     )

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




class 				UpperCamelCase_			(				UpperCamelCase):

	"""simple docstring"""





	snake_case__       :						int					      =    "blip"
	snake_case__       :						Optional[int]					      =    True




	def __init__(				self    :       Optional[int]    ,    UpperCAmelCase__    :       List[str]=None    ,    UpperCAmelCase__    :       Tuple=None    ,    UpperCAmelCase__    :       List[Any]=5_1_2    ,    UpperCAmelCase__    :       Optional[int]=2.6_592    ,    UpperCAmelCase__    :       List[str]=2_5_6    ,    **UpperCAmelCase__    :       Tuple    ,    ) ->			int:
						super().__init__(**UpperCAmelCase__     )

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

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

						__SCREAMING_SNAKE_CASE		     =       BlipTextConfig(**UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       BlipVisionConfig(**UpperCAmelCase__     )

						__SCREAMING_SNAKE_CASE		     =       self.vision_config.hidden_size

						__SCREAMING_SNAKE_CASE		     =       projection_dim
						__SCREAMING_SNAKE_CASE		     =       logit_scale_init_value
						__SCREAMING_SNAKE_CASE		     =       1.0
						__SCREAMING_SNAKE_CASE		     =       0.02
						__SCREAMING_SNAKE_CASE		     =       image_text_hidden_size




	@classmethod
	def 						UpperCAmelCase_   (				cls    :       List[Any]    ,    UpperCAmelCase__    :       BlipTextConfig    ,    UpperCAmelCase__    :       BlipVisionConfig    ,    **UpperCAmelCase__    :       List[Any]     ) ->			int:
						return cls(text_config=text_config.to_dict()    ,    vision_config=vision_config.to_dict()    ,    **UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       int     ) ->			Tuple:
						__SCREAMING_SNAKE_CASE		     =       copy.deepcopy(self.__dict__     )
						__SCREAMING_SNAKE_CASE		     =       self.text_config.to_dict()
						__SCREAMING_SNAKE_CASE		     =       self.vision_config.to_dict()
						__SCREAMING_SNAKE_CASE		     =       self.__class__.model_type
						return output




"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


a__       :							Optional[Any]        =  {
    '''configuration_jukebox''': [
        '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''JukeboxConfig''',
        '''JukeboxPriorConfig''',
        '''JukeboxVQVAEConfig''',
    ],
    '''tokenization_jukebox''': ['''JukeboxTokenizer'''],
}

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		a__       :							int        =  [
		    '''JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''JukeboxModel''',
		    '''JukeboxPreTrainedModel''',
		    '''JukeboxVQVAE''',
		    '''JukeboxPrior''',
		]

if TYPE_CHECKING:
		from .configuration_jukebox import (
		    JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    JukeboxConfig,
		    JukeboxPriorConfig,
		    JukeboxVQVAEConfig,
		)
		from .tokenization_jukebox import JukeboxTokenizer

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_jukebox import (
				    JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST,
				    JukeboxModel,
				    JukeboxPreTrainedModel,
				    JukeboxPrior,
				    JukeboxVQVAE,
				)

else:
		import sys

		a__       :							Union[str, Any]        =  _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
