"""simple docstring"""





import copy
import os
from typing import Union

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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''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  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"blip_text_model"





				def __init__(      self							:							Optional[int]      ,    _A							:							Dict=3_0_5_2_4      ,    _A							:							Union[str, Any]=7_6_8      ,    _A							:							Optional[int]=7_6_8      ,    _A							:							Tuple=3_0_7_2      ,    _A							:							List[Any]=7_6_8      ,    _A							:							Tuple=1_2      ,    _A							:							Tuple=8      ,    _A							:							List[str]=5_1_2      ,    _A							:							Optional[Any]="gelu"      ,    _A							:							Optional[Any]=1e-12      ,    _A							:							Optional[Any]=0.0      ,    _A							:							str=0.0      ,    _A							:							List[Any]=0.02      ,    _A							:							int=3_0_5_2_2      ,    _A							:							Union[str, Any]=2      ,    _A							:							List[Any]=0      ,    _A							:							str=1_0_2      ,    _A							:							int=True      ,    _A							:							Tuple=True      ,    **_A							:							List[str]      ,    ):



											"""simple docstring"""







											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 		_lowerCAmelCase		(      cls							:							Any      ,    _A							:							Union[str, os.PathLike]      ,    **_A							:							Optional[Any]):



											"""simple docstring"""







											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  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"blip_vision_model"





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



											"""simple docstring"""







											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 		_lowerCAmelCase		(      cls							:							str      ,    _A							:							Union[str, os.PathLike]      ,    **_A							:							List[str]):



											"""simple docstring"""







											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  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"blip"
				a			=						True





				def __init__(      self							:							Tuple      ,    _A							:							Any=None      ,    _A							:							List[str]=None      ,    _A							:							int=5_1_2      ,    _A							:							Dict=2.6_592      ,    _A							:							int=2_5_6      ,    **_A							:							str      ,    ):



											"""simple docstring"""







											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 		_lowerCAmelCase		(      cls							:							List[Any]      ,    _A							:							BlipTextConfig      ,    _A							:							BlipVisionConfig      ,    **_A							:							Any):



											"""simple docstring"""







											return cls(text_config=text_config.to_dict()      ,    vision_config=vision_config.to_dict()      ,    **_UpperCAmelCase)





				def 		_lowerCAmelCase		(      self							:							Union[str, Any]):



											"""simple docstring"""







											_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 __future__ import annotations



def      lowerCamelCase_(__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE     ,	)->    tuple:
							if (electron_conc, hole_conc, intrinsic_conc).count(0  ) != 1:
														raise ValueError("""You cannot supply more or less than 2 values"""  )
							elif electron_conc < 0:
														raise ValueError("""Electron concentration cannot be negative in a semiconductor"""  )
							elif hole_conc < 0:
														raise ValueError("""Hole concentration cannot be negative in a semiconductor"""  )
							elif intrinsic_conc < 0:
														raise ValueError(
														    """Intrinsic concentration cannot be negative in a semiconductor"""  )
							elif electron_conc == 0:
														return (
														    "electron_conc",
														    intrinsic_conc**2 / hole_conc,
														)
							elif hole_conc == 0:
														return (
														    "hole_conc",
														    intrinsic_conc**2 / electron_conc,
														)
							elif intrinsic_conc == 0:
														return (
														    "intrinsic_conc",
														    (electron_conc * hole_conc) ** 0.5,
														)
							else:
														return (-1, -1)


if __name__ == "__main__":
			import doctest

			doctest.testmod()


