


import copy
import os
from typing import Union

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


UpperCAmelCase_ :					Optional[int]       =			logging.get_logger(__name__)

UpperCAmelCase_ :					str       =			{
    '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 					SCREAMING_SNAKE_CASE__    (							__lowerCAmelCase     ):
      snake_case__							:	Optional[int]	  =		'''blip_text_model'''
      def __init__(			self							:			str	,				SCREAMING_SNAKE_CASE__							:			Optional[int]=3_0_5_2_4	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]=7_6_8	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]=7_6_8	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]=3_0_7_2	,				SCREAMING_SNAKE_CASE__							:			Optional[Any]=7_6_8	,				SCREAMING_SNAKE_CASE__							:			str=1_2	,				SCREAMING_SNAKE_CASE__							:			Optional[Any]=8	,				SCREAMING_SNAKE_CASE__							:			Any=5_1_2	,				SCREAMING_SNAKE_CASE__							:			Tuple="gelu"	,				SCREAMING_SNAKE_CASE__							:			Tuple=1E-12	,				SCREAMING_SNAKE_CASE__							:			Dict=0.0	,				SCREAMING_SNAKE_CASE__							:			Dict=0.0	,				SCREAMING_SNAKE_CASE__							:			Any=0.02	,				SCREAMING_SNAKE_CASE__							:			str=3_0_5_2_2	,				SCREAMING_SNAKE_CASE__							:			List[str]=2	,				SCREAMING_SNAKE_CASE__							:			List[str]=0	,				SCREAMING_SNAKE_CASE__							:			List[Any]=1_0_2	,				SCREAMING_SNAKE_CASE__							:			int=True	,				SCREAMING_SNAKE_CASE__							:			Optional[int]=True	,				**SCREAMING_SNAKE_CASE__							:			Optional[int]	,				)						->     List[Any]:
             super().__init__(
                 pad_token_id=_lowerCamelCase	,				bos_token_id=_lowerCamelCase	,				eos_token_id=_lowerCamelCase	,				sep_token_id=_lowerCamelCase	,				**_lowerCamelCase	,				)

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

      @classmethod
      def 			SCREAMING_SNAKE_CASE				(			cls							:			Union[str, Any]	,				SCREAMING_SNAKE_CASE__							:			Dict	,				**SCREAMING_SNAKE_CASE__							:			Optional[int]	)						->     Optional[int]:
             cls._set_token_in_kwargs(_lowerCamelCase	)

             a_				,						a_   :						Optional[int]				=    cls.get_config_dict(_lowerCamelCase	,				**_lowerCamelCase	)

             # get the text config dict if we are loading from BlipConfig
             if config_dict.get('model_type'	) == "blip":
                    a_   :						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(_lowerCamelCase	,				**_lowerCamelCase	)
class 					SCREAMING_SNAKE_CASE__    (							__lowerCAmelCase     ):
      snake_case__							:	Dict	  =		'''blip_vision_model'''
      def __init__(			self							:			str	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]=7_6_8	,				SCREAMING_SNAKE_CASE__							:			Optional[int]=3_0_7_2	,				SCREAMING_SNAKE_CASE__							:			Any=5_1_2	,				SCREAMING_SNAKE_CASE__							:			Tuple=1_2	,				SCREAMING_SNAKE_CASE__							:			List[Any]=1_2	,				SCREAMING_SNAKE_CASE__							:			List[Any]=3_8_4	,				SCREAMING_SNAKE_CASE__							:			List[str]=1_6	,				SCREAMING_SNAKE_CASE__							:			Dict="gelu"	,				SCREAMING_SNAKE_CASE__							:			Optional[Any]=1E-5	,				SCREAMING_SNAKE_CASE__							:			Dict=0.0	,				SCREAMING_SNAKE_CASE__							:			Any=1E-10	,				**SCREAMING_SNAKE_CASE__							:			Tuple	,				)						->     int:
             super().__init__(**_lowerCamelCase	)

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

      @classmethod
      def 			SCREAMING_SNAKE_CASE				(			cls							:			Union[str, Any]	,				SCREAMING_SNAKE_CASE__							:			Optional[Any]	,				**SCREAMING_SNAKE_CASE__							:			Union[str, Any]	)						->     Optional[int]:
             cls._set_token_in_kwargs(_lowerCamelCase	)

             a_				,						a_   :						Dict				=    cls.get_config_dict(_lowerCamelCase	,				**_lowerCamelCase	)

             # get the vision config dict if we are loading from BlipConfig
             if config_dict.get('model_type'	) == "blip":
                    a_   :						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(_lowerCamelCase	,				**_lowerCamelCase	)
class 					SCREAMING_SNAKE_CASE__    (							__lowerCAmelCase     ):
      snake_case__							:	List[Any]	  =		'''blip'''
      snake_case__							:	int	  =		True
      def __init__(			self							:			str	,				SCREAMING_SNAKE_CASE__							:			List[Any]=None	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]=None	,				SCREAMING_SNAKE_CASE__							:			List[str]=5_1_2	,				SCREAMING_SNAKE_CASE__							:			Tuple=2.6592	,				SCREAMING_SNAKE_CASE__							:			str=2_5_6	,				**SCREAMING_SNAKE_CASE__							:			Optional[Any]	,				)						->     Any:
             super().__init__(**_lowerCamelCase	)

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

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

             a_   :						Tuple				=    BlipTextConfig(**_lowerCamelCase	)
             a_   :						Dict				=    BlipVisionConfig(**_lowerCamelCase	)

             a_   :						List[str]				=    self.vision_config.hidden_size

             a_   :						List[Any]				=    projection_dim
             a_   :						int				=    logit_scale_init_value
             a_   :						List[str]				=    1.0
             a_   :						Dict				=    0.02
             a_   :						Union[str, Any]				=    image_text_hidden_size
      @classmethod
      def 			SCREAMING_SNAKE_CASE				(			cls							:			Dict	,				SCREAMING_SNAKE_CASE__							:			Union[str, Any]	,				SCREAMING_SNAKE_CASE__							:			Optional[Any]	,				**SCREAMING_SNAKE_CASE__							:			Union[str, Any]	)						->     Dict:
             return cls(text_config=text_config.to_dict()	,				vision_config=vision_config.to_dict()	,				**_lowerCamelCase	)

      def 			SCREAMING_SNAKE_CASE				(			self							:			List[str]	)						->     Any:
             a_   :						Optional[Any]				=    copy.deepcopy(self.__dict__	)
             a_   :						Optional[int]				=    self.text_config.to_dict()
             a_   :						Tuple				=    self.vision_config.to_dict()
             a_   :						List[str]				=    self.__class__.model_type
             return output



"""simple docstring"""


def      lowerCamelCase_					(   __lowerCAmelCase							)				->   "list[int]":




						'''simple docstring'''



						if upper_limit < 0:
												raise ValueError("Limit for the Catalan sequence must be ≥ 0"							)

						lowerCamelCase__   =[0] * (upper_limit + 1)

						# Base case: C(0) = C(1) = 1
						lowerCamelCase__   =1
						if upper_limit > 0:
												lowerCamelCase__   =1

						# Recurrence relation: C(i) = sum(C(j).C(i-j-1)), from j = 0 to i
						for i in range(2  ,       upper_limit + 1							):
												for j in range(__lowerCAmelCase							):
																		catalan_list[i] += catalan_list[j] * catalan_list[i - j - 1]

						return catalan_list


if __name__ == "__main__":
	print('\n********* Catalan Numbers Using Dynamic Programming ************\n')
	print('\n*** Enter -1 at any time to quit ***')
	print('\nEnter the upper limit (≥ 0) for the Catalan number sequence: ', end='')
	try:
		while True:
			a				=int(input().strip())
			if N < 0:
				print('\n********* Goodbye!! ************')
				break
			else:
				print(F'''The Catalan numbers from 0 through {N} are:''')
				print(catalan_numbers(N))
				print('Try another upper limit for the sequence: ', end='')
	except (NameError, ValueError):
		print('\n********* Invalid input, goodbye! ************\n')

	import doctest

	doctest.testmod()


