




"""simple docstring"""






import copy
import os
from typing import Union

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


lowercase__     						=						logging.get_logger(__name__)

lowercase__     						=						{
    """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 lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			"""blip_text_model"""
			def __init__(  self  ,      lowercase=30524  ,      lowercase=768  ,      lowercase=768  ,      lowercase=3072  ,      lowercase=768  ,      lowercase=12  ,      lowercase=8  ,      lowercase=512  ,      lowercase="gelu"  ,      lowercase=1E-12  ,      lowercase=0.0  ,      lowercase=0.0  ,      lowercase=0.02  ,      lowercase=30522  ,      lowercase=2  ,      lowercase=0  ,      lowercase=102  ,      lowercase=True  ,      lowercase=True  ,      **lowercase  ,      ):
							super().__init__(
							    pad_token_id=lowercase  ,      bos_token_id=lowercase  ,      eos_token_id=lowercase  ,      sep_token_id=lowercase  ,      **lowercase  ,      )

							_lowerCamelCase     :			List[str]    =    vocab_size
							_lowerCamelCase     :			Tuple    =    hidden_size
							_lowerCamelCase     :			Optional[int]    =    encoder_hidden_size
							_lowerCamelCase     :			List[Any]    =    intermediate_size
							_lowerCamelCase     :			Optional[Any]    =    projection_dim
							_lowerCamelCase     :			Tuple    =    hidden_dropout_prob
							_lowerCamelCase     :			Tuple    =    num_hidden_layers
							_lowerCamelCase     :			int    =    num_attention_heads
							_lowerCamelCase     :			Optional[Any]    =    max_position_embeddings
							_lowerCamelCase     :			Optional[int]    =    layer_norm_eps
							_lowerCamelCase     :			List[Any]    =    hidden_act
							_lowerCamelCase     :			Tuple    =    initializer_range
							_lowerCamelCase     :			int    =    attention_probs_dropout_prob
							_lowerCamelCase     :			List[str]    =    is_decoder
							_lowerCamelCase     :			Optional[Any]    =    use_cache






			@classmethod
			def 					A_    (  cls  ,      lowercase  ,      **lowercase  ):
							cls._set_token_in_kwargs(lowercase  )

							_lowerCamelCase, _lowerCamelCase     :			int    =    cls.get_config_dict(lowercase  ,      **lowercase  )

							# get the text config dict if we are loading from BlipConfig
							if config_dict.get('model_type'  ) == "blip":
											_lowerCamelCase     :			Union[str, Any]    =    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(lowercase  ,      **lowercase  )






class lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			"""blip_vision_model"""
			def __init__(  self  ,      lowercase=768  ,      lowercase=3072  ,      lowercase=512  ,      lowercase=12  ,      lowercase=12  ,      lowercase=384  ,      lowercase=16  ,      lowercase="gelu"  ,      lowercase=1E-5  ,      lowercase=0.0  ,      lowercase=1E-10  ,      **lowercase  ,      ):
							super().__init__(**lowercase  )

							_lowerCamelCase     :			Union[str, Any]    =    hidden_size
							_lowerCamelCase     :			List[str]    =    intermediate_size
							_lowerCamelCase     :			Any    =    projection_dim
							_lowerCamelCase     :			List[Any]    =    num_hidden_layers
							_lowerCamelCase     :			Any    =    num_attention_heads
							_lowerCamelCase     :			List[Any]    =    patch_size
							_lowerCamelCase     :			Union[str, Any]    =    image_size
							_lowerCamelCase     :			Optional[int]    =    initializer_range
							_lowerCamelCase     :			Optional[int]    =    attention_dropout
							_lowerCamelCase     :			List[Any]    =    layer_norm_eps
							_lowerCamelCase     :			Tuple    =    hidden_act






			@classmethod
			def 					A_    (  cls  ,      lowercase  ,      **lowercase  ):
							cls._set_token_in_kwargs(lowercase  )

							_lowerCamelCase, _lowerCamelCase     :			List[Any]    =    cls.get_config_dict(lowercase  ,      **lowercase  )

							# get the vision config dict if we are loading from BlipConfig
							if config_dict.get('model_type'  ) == "blip":
											_lowerCamelCase     :			List[Any]    =    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(lowercase  ,      **lowercase  )






class lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			"""blip"""
			lowerCamelCase__      =			True
			def __init__(  self  ,      lowercase=None  ,      lowercase=None  ,      lowercase=512  ,      lowercase=2.65_92  ,      lowercase=256  ,      **lowercase  ,      ):
							super().__init__(**lowercase  )

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

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

							_lowerCamelCase     :			Dict    =    BlipTextConfig(**lowercase  )
							_lowerCamelCase     :			Optional[Any]    =    BlipVisionConfig(**lowercase  )

							_lowerCamelCase     :			int    =    self.vision_config.hidden_size

							_lowerCamelCase     :			List[str]    =    projection_dim
							_lowerCamelCase     :			List[Any]    =    logit_scale_init_value
							_lowerCamelCase     :			str    =    1.0
							_lowerCamelCase     :			List[Any]    =    0.02
							_lowerCamelCase     :			List[Any]    =    image_text_hidden_size
			@classmethod
			def 					A_    (  cls  ,      lowercase  ,      lowercase  ,      **lowercase  ):
							return cls(text_config=text_config.to_dict()  ,      vision_config=vision_config.to_dict()  ,      **lowercase  )






			def 					A_    (  self  ):
							_lowerCamelCase     :			Dict    =    copy.deepcopy(self.__dict__  )
							_lowerCamelCase     :			Optional[Any]    =    self.text_config.to_dict()
							_lowerCamelCase     :			str    =    self.vision_config.to_dict()
							_lowerCamelCase     :			Optional[Any]    =    self.__class__.model_type
							return output





"""simple docstring"""






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


lowercase__     						=						logging.get_logger(__name__)

lowercase__     						=						{"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""}






class lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			"""ctrl"""
			lowerCamelCase__      =			["""past_key_values"""]
			lowerCamelCase__      =			{
			    """max_position_embeddings""": """n_positions""",
			    """hidden_size""": """n_embd""",
			    """num_attention_heads""": """n_head""",
			    """num_hidden_layers""": """n_layer""",
			}
			def __init__(  self  ,      lowercase=246534  ,      lowercase=256  ,      lowercase=1280  ,      lowercase=8192  ,      lowercase=48  ,      lowercase=16  ,      lowercase=0.1  ,      lowercase=0.1  ,      lowercase=1E-6  ,      lowercase=0.02  ,      lowercase=True  ,      **lowercase  ,      ):
							_lowerCamelCase     :			Any    =    vocab_size
							_lowerCamelCase     :			Dict    =    n_positions
							_lowerCamelCase     :			Optional[int]    =    n_embd
							_lowerCamelCase     :			str    =    n_layer
							_lowerCamelCase     :			Union[str, Any]    =    n_head
							_lowerCamelCase     :			Any    =    dff
							_lowerCamelCase     :			int    =    resid_pdrop
							_lowerCamelCase     :			Dict    =    embd_pdrop
							_lowerCamelCase     :			Union[str, Any]    =    layer_norm_epsilon
							_lowerCamelCase     :			Tuple    =    initializer_range

							_lowerCamelCase     :			str    =    use_cache

							super().__init__(**lowercase  )