


'''simple docstring'''






import copy
import os
from typing import Union

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


__UpperCAmelCase       							=				logging.get_logger(__name__)

__UpperCAmelCase       							=				{
    '''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 						a__							(				a__    ):





							'''simple docstring'''






							lowercase__     :  Any      		= "blip_text_model"







							def __init__(						self   ,       lowerCamelCase_=3_05_24   ,       lowerCamelCase_=7_68   ,       lowerCamelCase_=7_68   ,       lowerCamelCase_=30_72   ,       lowerCamelCase_=7_68   ,       lowerCamelCase_=12   ,       lowerCamelCase_=8   ,       lowerCamelCase_=5_12   ,       lowerCamelCase_="gelu"   ,       lowerCamelCase_=1e-12   ,       lowerCamelCase_=0.0   ,       lowerCamelCase_=0.0   ,       lowerCamelCase_=0.02   ,       lowerCamelCase_=3_05_22   ,       lowerCamelCase_=2   ,       lowerCamelCase_=0   ,       lowerCamelCase_=1_02   ,       lowerCamelCase_=True   ,       lowerCamelCase_=True   ,       **lowerCamelCase_   ,       )			->				Any:
														super().__init__(
														    pad_token_id=lowerCamelCase_   ,       bos_token_id=lowerCamelCase_   ,       eos_token_id=lowerCamelCase_   ,       sep_token_id=lowerCamelCase_   ,       **lowerCamelCase_   ,       )

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







							@classmethod
							def     __SCREAMING_SNAKE_CASE				(						cls   ,       lowerCamelCase_   ,       **lowerCamelCase_  )			->				"PretrainedConfig":
														cls._set_token_in_kwargs(lowerCamelCase_  )

														lowerCAmelCase__  ,   lowerCAmelCase__			  =      cls.get_config_dict(lowerCamelCase_   ,       **lowerCamelCase_  )

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




class 						a__							(				a__    ):





							'''simple docstring'''






							lowercase__     :  Optional[int]      		= "blip_vision_model"







							def __init__(						self   ,       lowerCamelCase_=7_68   ,       lowerCamelCase_=30_72   ,       lowerCamelCase_=5_12   ,       lowerCamelCase_=12   ,       lowerCamelCase_=12   ,       lowerCamelCase_=3_84   ,       lowerCamelCase_=16   ,       lowerCamelCase_="gelu"   ,       lowerCamelCase_=1e-5   ,       lowerCamelCase_=0.0   ,       lowerCamelCase_=1e-10   ,       **lowerCamelCase_   ,       )			->				List[str]:
														super().__init__(**lowerCamelCase_  )

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







							@classmethod
							def     __SCREAMING_SNAKE_CASE				(						cls   ,       lowerCamelCase_   ,       **lowerCamelCase_  )			->				"PretrainedConfig":
														cls._set_token_in_kwargs(lowerCamelCase_  )

														lowerCAmelCase__  ,   lowerCAmelCase__			  =      cls.get_config_dict(lowerCamelCase_   ,       **lowerCamelCase_  )

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






							lowercase__     :  Optional[int]      		= "blip"
							lowercase__     :  Union[str, Any]      		= True







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

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

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

														lowerCAmelCase__			  =      BlipTextConfig(**lowerCamelCase_  )
														lowerCAmelCase__			  =      BlipVisionConfig(**lowerCamelCase_  )

														lowerCAmelCase__			  =      self.vision_config.hidden_size

														lowerCAmelCase__			  =      projection_dim
														lowerCAmelCase__			  =      logit_scale_init_value
														lowerCAmelCase__			  =      1.0
														lowerCAmelCase__			  =      0.02
														lowerCAmelCase__			  =      image_text_hidden_size







							@classmethod
							def     __SCREAMING_SNAKE_CASE				(						cls   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       **lowerCamelCase_  )			->				Union[str, Any]:
														return cls(text_config=text_config.to_dict()   ,       vision_config=vision_config.to_dict()   ,       **lowerCamelCase_  )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Optional[int]:
														lowerCAmelCase__			  =      copy.deepcopy(self.__dict__  )
														lowerCAmelCase__			  =      self.text_config.to_dict()
														lowerCAmelCase__			  =      self.vision_config.to_dict()
														lowerCAmelCase__			  =      self.__class__.model_type
														return output



'''simple docstring'''






import warnings
from functools import wraps
from typing import Callable





def lowerCamelCase__     (		__lowerCamelCase			:				Callable				):







   '''simple docstring'''




   @wraps(__lowerCamelCase				)
   def _inner_fn(*__lowerCamelCase			:				int			,       **__lowerCamelCase			:				Optional[Any]				):
      warnings.warn(
          (f"'{fn.__name__}' is experimental and might be subject to breaking changes in the future.")			,       __lowerCamelCase			,       )
      return fn(*__lowerCamelCase			,       **__lowerCamelCase				)

   return _inner_fn

