





import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


UpperCAmelCase						:   int			  =     logging.get_logger(__name__)

UpperCAmelCase						:   Any			  =     {
    '''salesforce/blip2-opt-2.7b''': '''https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json''',
}





class 						_A(					snake_case__   ):


				"""simple docstring"""


				UpperCamelCase    :  int					    =	'''blip_2_vision_model'''



				def __init__(			self     ,					_A=1408     ,					_A=6144     ,					_A=39     ,					_A=16     ,					_A=224     ,					_A=14     ,					_A="gelu"     ,					_A=0.0_0_0_0_1     ,					_A=0.0     ,					_A=1e-1_0     ,					_A=True     ,					**_A     ,					):
									super().__init__(**_A     )

									__A	:						Dict       =				hidden_size
									__A	:						Dict       =				intermediate_size
									__A	:						List[str]       =				num_hidden_layers
									__A	:						List[Any]       =				num_attention_heads
									__A	:						List[Any]       =				patch_size
									__A	:						List[str]       =				image_size
									__A	:						Optional[Any]       =				initializer_range
									__A	:						Optional[Any]       =				attention_dropout
									__A	:						List[str]       =				layer_norm_eps
									__A	:						Dict       =				hidden_act
									__A	:						List[str]       =				qkv_bias





				@classmethod
				def 					UpperCAmelCase_		(			cls     ,					_A     ,					**_A     ):
									cls._set_token_in_kwargs(_A     )

									__A    ,				__A	:						Any       =				cls.get_config_dict(_A     ,					**_A     )

									# get the vision config dict if we are loading from Blip2Config
									if config_dict.get('model_type'     ) == "blip-2":
														__A	:						Union[str, 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(_A     ,					**_A     )





class 						_A(					snake_case__   ):


				"""simple docstring"""


				UpperCamelCase    :  int					    =	'''blip_2_qformer'''



				def __init__(			self     ,					_A=30522     ,					_A=768     ,					_A=12     ,					_A=12     ,					_A=3072     ,					_A="gelu"     ,					_A=0.1     ,					_A=0.1     ,					_A=512     ,					_A=0.0_2     ,					_A=1e-1_2     ,					_A=0     ,					_A="absolute"     ,					_A=2     ,					_A=1408     ,					**_A     ,					):
									super().__init__(pad_token_id=_A     ,					**_A     )

									__A	:						Any       =				vocab_size
									__A	:						str       =				hidden_size
									__A	:						Optional[Any]       =				num_hidden_layers
									__A	:						Any       =				num_attention_heads
									__A	:						Union[str, Any]       =				hidden_act
									__A	:						Optional[Any]       =				intermediate_size
									__A	:						List[str]       =				hidden_dropout_prob
									__A	:						Tuple       =				attention_probs_dropout_prob
									__A	:						Optional[Any]       =				max_position_embeddings
									__A	:						str       =				initializer_range
									__A	:						str       =				layer_norm_eps
									__A	:						Optional[int]       =				position_embedding_type
									__A	:						str       =				cross_attention_frequency
									__A	:						Optional[Any]       =				encoder_hidden_size





				@classmethod
				def 					UpperCAmelCase_		(			cls     ,					_A     ,					**_A     ):
									cls._set_token_in_kwargs(_A     )

									__A    ,				__A	:						Optional[int]       =				cls.get_config_dict(_A     ,					**_A     )

									# get the qformer config dict if we are loading from Blip2Config
									if config_dict.get('model_type'     ) == "blip-2":
														__A	:						str       =				config_dict['qformer_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(_A     ,					**_A     )





class 						_A(					snake_case__   ):


				"""simple docstring"""


				UpperCamelCase    :  Tuple					    =	'''blip-2'''
				UpperCamelCase    :  str					    =	True



				def __init__(			self     ,					_A=None     ,					_A=None     ,					_A=None     ,					_A=32     ,					**_A     ):
									super().__init__(**_A     )

									if vision_config is None:
														__A	:						Any       =				{}
														logger.info('vision_config is None. initializing the Blip2VisionConfig with default values.'     )

									if qformer_config is None:
														__A	:						str       =				{}
														logger.info('qformer_config is None. Initializing the Blip2QFormerConfig with default values.'     )

									if text_config is None:
														__A	:						Any       =				{}
														logger.info('text_config is None. Initializing the text config with default values (`OPTConfig`).'     )

									__A	:						Dict       =				BlipaVisionConfig(**_A     )
									__A	:						Dict       =				BlipaQFormerConfig(**_A     )
									__A	:						Dict       =				text_config['model_type'] if 'model_type' in text_config else 'opt'
									__A	:						Union[str, Any]       =				CONFIG_MAPPING[text_model_type](**_A     )

									__A	:						Dict       =				self.text_config.tie_word_embeddings
									__A	:						str       =				self.text_config.is_encoder_decoder

									__A	:						Dict       =				num_query_tokens
									__A	:						Any       =				self.vision_config.hidden_size
									__A	:						List[str]       =				self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
									__A	:						Dict       =				1.0
									__A	:						str       =				0.0_2



				@classmethod
				def 					UpperCAmelCase_		(			cls     ,					_A     ,					_A     ,					_A     ,					**_A     ,					):
									return cls(
									    vision_config=vision_config.to_dict()     ,					qformer_config=qformer_config.to_dict()     ,					text_config=text_config.to_dict()     ,					**_A     ,					)





				def 					UpperCAmelCase_		(			self     ):
									__A	:						Any       =				copy.deepcopy(self.__dict__     )
									__A	:						Any       =				self.vision_config.to_dict()
									__A	:						Optional[Any]       =				self.qformer_config.to_dict()
									__A	:						Dict       =				self.text_config.to_dict()
									__A	:						Optional[int]       =				self.__class__.model_type
									return output











def  _SCREAMING_SNAKE_CASE				(   a  )      ->      bool:
					return str(a  ) == str(a  )[::-1]







def  _SCREAMING_SNAKE_CASE				(   a  )      ->      int:
					return int(a  ) + int(str(a  )[::-1]  )







def  _SCREAMING_SNAKE_CASE				(   a = 1_00_00  )      ->      int:
					__A	:						int       =				[]
					for num in range(1					,						a  ):
										__A	:						List[str]       =				0
										__A	:						List[Any]       =				num
										while iterations < 50:
															__A	:						str       =				sum_reverse(a  )
															iterations += 1
															if is_palindrome(a  ):
																				break
										else:
															lychrel_nums.append(a  )
					return len(a  )


if __name__ == "__main__":
				print(F"""{solution() = }""")




