


"""simple docstring"""







import copy
import os
from typing import Union

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


a__    :							List[Any]            =					logging.get_logger(__name__)

a__    :							Tuple            =					{
    '''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_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  int    =      "blip_text_model"




	def __init__(			self      :    Any      ,      UpperCAmelCase__      :    List[Any]=3_0_5_2_4      ,      UpperCAmelCase__      :    Optional[Any]=7_6_8      ,      UpperCAmelCase__      :    List[str]=7_6_8      ,      UpperCAmelCase__      :    Dict=3_0_7_2      ,      UpperCAmelCase__      :    List[Any]=7_6_8      ,      UpperCAmelCase__      :    Optional[Any]=1_2      ,      UpperCAmelCase__      :    str=8      ,      UpperCAmelCase__      :    Optional[int]=5_1_2      ,      UpperCAmelCase__      :    Optional[int]="gelu"      ,      UpperCAmelCase__      :    Any=1E-12      ,      UpperCAmelCase__      :    Any=0.0      ,      UpperCAmelCase__      :    Union[str, Any]=0.0      ,      UpperCAmelCase__      :    int=0.02      ,      UpperCAmelCase__      :    Optional[Any]=3_0_5_2_2      ,      UpperCAmelCase__      :    Optional[Any]=2      ,      UpperCAmelCase__      :    List[Any]=0      ,      UpperCAmelCase__      :    Any=1_0_2      ,      UpperCAmelCase__      :    Any=True      ,      UpperCAmelCase__      :    Optional[int]=True      ,      **UpperCAmelCase__      :    Optional[int]      ,      )	->     Any:
						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   UpperCAmelCase_				(			cls      :    int      ,      UpperCAmelCase__      :    Union[str, os.PathLike]      ,      **UpperCAmelCase__      :    Tuple       )	->     "PretrainedConfig":
						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 			UpperCamelCase_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  str    =      "blip_vision_model"




	def __init__(			self      :    Union[str, Any]      ,      UpperCAmelCase__      :    Dict=7_6_8      ,      UpperCAmelCase__      :    List[Any]=3_0_7_2      ,      UpperCAmelCase__      :    Union[str, Any]=5_1_2      ,      UpperCAmelCase__      :    Any=1_2      ,      UpperCAmelCase__      :    int=1_2      ,      UpperCAmelCase__      :    List[str]=3_8_4      ,      UpperCAmelCase__      :    Tuple=1_6      ,      UpperCAmelCase__      :    Optional[Any]="gelu"      ,      UpperCAmelCase__      :    List[str]=1E-5      ,      UpperCAmelCase__      :    List[str]=0.0      ,      UpperCAmelCase__      :    Tuple=1E-10      ,      **UpperCAmelCase__      :    List[Any]      ,      )	->     Tuple:
						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   UpperCAmelCase_				(			cls      :    Optional[Any]      ,      UpperCAmelCase__      :    Union[str, os.PathLike]      ,      **UpperCAmelCase__      :    str       )	->     "PretrainedConfig":
						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 			UpperCamelCase_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  Optional[Any]    =      "blip"
	snake_case__    :  Optional[int]    =      True




	def __init__(			self      :    Tuple      ,      UpperCAmelCase__      :    Optional[Any]=None      ,      UpperCAmelCase__      :    Dict=None      ,      UpperCAmelCase__      :    Union[str, Any]=5_1_2      ,      UpperCAmelCase__      :    List[str]=2.6_592      ,      UpperCAmelCase__      :    int=2_5_6      ,      **UpperCAmelCase__      :    str      ,      )	->     Union[str, Any]:
						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   UpperCAmelCase_				(			cls      :    List[Any]      ,      UpperCAmelCase__      :    BlipTextConfig      ,      UpperCAmelCase__      :    BlipVisionConfig      ,      **UpperCAmelCase__      :    List[Any]       )	->     Union[str, Any]:
						return cls(text_config=text_config.to_dict()      ,      vision_config=vision_config.to_dict()      ,      **UpperCAmelCase__       )




	def   UpperCAmelCase_				(			self      :    List[str]       )	->     str:
						__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"""







def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    [0 for i in range(r + 1       )]
					# nc0 = 1
					__SCREAMING_SNAKE_CASE						       =    1
					for i in range(1  ,						n + 1       ):
										# to compute current row from previous row.
										__SCREAMING_SNAKE_CASE						       =    min(lowerCAmelCase_  ,						lowerCAmelCase_       )
										while j > 0:
															c[j] += c[j - 1]
															j -= 1
					return c[r]



print(binomial_coefficient(n=1_0, r=5))
