"""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		(      __lowerCAmelCase      ):
				A__ :  Optional[int]    				=			'''blip_text_model'''

				def __init__( self      ,					_lowerCamelCase=30524      ,					_lowerCamelCase=768      ,					_lowerCamelCase=768      ,					_lowerCamelCase=3072      ,					_lowerCamelCase=768      ,					_lowerCamelCase=12      ,					_lowerCamelCase=8      ,					_lowerCamelCase=512      ,					_lowerCamelCase="gelu"      ,					_lowerCamelCase=1E-12      ,					_lowerCamelCase=0.0      ,					_lowerCamelCase=0.0      ,					_lowerCamelCase=0.0_2      ,					_lowerCamelCase=30522      ,					_lowerCamelCase=2      ,					_lowerCamelCase=0      ,					_lowerCamelCase=102      ,					_lowerCamelCase=True      ,					_lowerCamelCase=True      ,					**_lowerCamelCase      ,					):
										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 						_a      ( cls      ,					_lowerCamelCase      ,					**_lowerCamelCase ):
										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   __UpperCAmelCase		(      __lowerCAmelCase      ):
				A__ :  Dict    				=			'''blip_vision_model'''

				def __init__( self      ,					_lowerCamelCase=768      ,					_lowerCamelCase=3072      ,					_lowerCamelCase=512      ,					_lowerCamelCase=12      ,					_lowerCamelCase=12      ,					_lowerCamelCase=384      ,					_lowerCamelCase=16      ,					_lowerCamelCase="gelu"      ,					_lowerCamelCase=1E-5      ,					_lowerCamelCase=0.0      ,					_lowerCamelCase=1E-10      ,					**_lowerCamelCase      ,					):
										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 						_a      ( cls      ,					_lowerCamelCase      ,					**_lowerCamelCase ):
										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   __UpperCAmelCase		(      __lowerCAmelCase      ):
				A__ :  List[Any]    				=			'''blip'''
				A__ :  int    				=			True

				def __init__( self      ,					_lowerCamelCase=None      ,					_lowerCamelCase=None      ,					_lowerCamelCase=512      ,					_lowerCamelCase=2.6_5_9_2      ,					_lowerCamelCase=256      ,					**_lowerCamelCase      ,					):
										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.0_2
										lowerCamelCase__   =image_text_hidden_size

				@classmethod
				def 						_a      ( cls      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					**_lowerCamelCase ):
										return cls(text_config=text_config.to_dict()      ,					vision_config=vision_config.to_dict()      ,					**_lowerCamelCase )






				def 						_a      ( self ):
										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"""


from .imports import is_rich_available


if is_rich_available():
	from rich.traceback import install

	install(show_locals=False)

else:
	raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')


