
"""simple docstring"""






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


_lowercase							=				logging.get_logger(__name__)

_lowercase							=				{
    '''Salesforce/instruct-blip-flan-t5''': '''https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json''',
}

class 					__a     ( __a       ):



							'''simple docstring'''







							_lowerCamelCase					:			Union[str, Any]          =   """instructblip_vision_model"""
							def __init__(     self  ,    _lowerCamelCase=1_408  ,    _lowerCamelCase=6_144  ,    _lowerCamelCase=39  ,    _lowerCamelCase=16  ,    _lowerCamelCase=224  ,    _lowerCamelCase=14  ,    _lowerCamelCase="gelu"  ,    _lowerCamelCase=1e-6  ,    _lowerCamelCase=0.0  ,    _lowerCamelCase=1e-10  ,    _lowerCamelCase=True  ,    **_lowerCamelCase  ,    )			->							int:




										'''simple docstring'''
										super().__init__(**_lowerCamelCase       )

										__lowercase       =       hidden_size
										__lowercase       =       intermediate_size
										__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
										__lowercase       =       qkv_bias





							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    **_lowerCamelCase       )			->							"PretrainedConfig":




										'''simple docstring'''
										cls._set_token_in_kwargs(_lowerCamelCase       )

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

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





class 					__a     ( __a       ):



							'''simple docstring'''







							_lowerCamelCase					:			Any          =   """instructblip_qformer"""
							def __init__(     self  ,    _lowerCamelCase=30_522  ,    _lowerCamelCase=768  ,    _lowerCamelCase=12  ,    _lowerCamelCase=12  ,    _lowerCamelCase=3_072  ,    _lowerCamelCase="gelu"  ,    _lowerCamelCase=0.1  ,    _lowerCamelCase=0.1  ,    _lowerCamelCase=512  ,    _lowerCamelCase=0.02  ,    _lowerCamelCase=1e-12  ,    _lowerCamelCase=0  ,    _lowerCamelCase="absolute"  ,    _lowerCamelCase=2  ,    _lowerCamelCase=1_408  ,    **_lowerCamelCase  ,    )			->							Optional[int]:




										'''simple docstring'''
										super().__init__(pad_token_id=_lowerCamelCase  ,    **_lowerCamelCase       )

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





							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    **_lowerCamelCase       )			->							"PretrainedConfig":




										'''simple docstring'''
										cls._set_token_in_kwargs(_lowerCamelCase       )

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

										# get the qformer config dict if we are loading from InstructBlipConfig
										if config_dict.get("model_type"       ) == "instructblip":
													__lowercase       =       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 					__a     ( __a       ):



							'''simple docstring'''







							_lowerCamelCase					:			Optional[int]          =   """instructblip"""
							_lowerCamelCase					:			Dict          =   True
							def __init__(     self  ,    _lowerCamelCase=None  ,    _lowerCamelCase=None  ,    _lowerCamelCase=None  ,    _lowerCamelCase=32  ,    **_lowerCamelCase       )			->							Dict:




										'''simple docstring'''
										super().__init__(**_lowerCamelCase       )

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

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

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

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

										__lowercase       =       self.text_config.tie_word_embeddings
										__lowercase       =       self.text_config.is_encoder_decoder

										__lowercase       =       num_query_tokens
										__lowercase       =       self.vision_config.hidden_size
										__lowercase       =       self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
										__lowercase       =       1.0
										__lowercase       =       0.02
							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    **_lowerCamelCase  ,    )			->							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       )			->							Union[str, Any]:




										'''simple docstring'''
										__lowercase       =       copy.deepcopy(self.__dict__       )
										__lowercase       =       self.vision_config.to_dict()
										__lowercase       =       self.qformer_config.to_dict()
										__lowercase       =       self.text_config.to_dict()
										__lowercase       =       self.__class__.model_type
										return output







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


_lowercase							=				{'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_lowercase							=				[
					    '''VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''ViTMAEForPreTraining''',
					    '''ViTMAELayer''',
					    '''ViTMAEModel''',
					    '''ViTMAEPreTrainedModel''',
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_lowercase							=				[
					    '''TFViTMAEForPreTraining''',
					    '''TFViTMAEModel''',
					    '''TFViTMAEPreTrainedModel''',
					]

if TYPE_CHECKING:
					from .configuration_vit_mae import VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMAEConfig

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_vit_mae import (
										    VIT_MAE_PRETRAINED_MODEL_ARCHIVE_LIST,
										    ViTMAEForPreTraining,
										    ViTMAELayer,
										    ViTMAEModel,
										    ViTMAEPreTrainedModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_vit_mae import TFViTMAEForPreTraining, TFViTMAEModel, TFViTMAEPreTrainedModel


else:
					import sys

					_lowercase							=				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





