






'''simple docstring'''





import copy
import os
from typing import Union

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


_UpperCamelCase						:						Dict  =					logging.get_logger(__name__)

_UpperCamelCase						:						Any  =					{
    'BridgeTower/bridgetower-base': 'https://huggingface.co/BridgeTower/bridgetower-base/blob/main/config.json',
    'BridgeTower/bridgetower-base-itm-mlm': (
        'https://huggingface.co/BridgeTower/bridgetower-base-itm-mlm/blob/main/config.json'
    ),
}


class  snake_case__      (					UpperCamelCase):
					a_        =					"bridgetower_vision_model"




					def __init__(  self  :		Tuple				, _A  :		Dict=7_68				, _A  :		List[Any]=12				, _A  :		Tuple=3				, _A  :		Optional[int]=16				, _A  :		Union[str, Any]=2_88				, _A  :		List[str]=1				, _A  :		List[str]=1e-05				, _A  :		Tuple=False				, _A  :		Tuple=True				, _A  :		Union[str, Any]=False				, **_A  :		List[str]				, )    ->							str:
								super().__init__(**_A      )
								UpperCAmelCase_      :       Union[str, Any]          =       hidden_size
								UpperCAmelCase_      :       List[str]          =       num_hidden_layers
								UpperCAmelCase_      :       List[str]          =       num_channels
								UpperCAmelCase_      :       Optional[Any]          =       patch_size
								UpperCAmelCase_      :       List[str]          =       image_size
								UpperCAmelCase_      :       Optional[Any]          =       initializer_factor
								UpperCAmelCase_      :       List[str]          =       layer_norm_eps
								UpperCAmelCase_      :       List[Any]          =       stop_gradient
								UpperCAmelCase_      :       Tuple          =       share_layernorm
								UpperCAmelCase_      :       List[Any]          =       remove_last_layer





					@classmethod
					def 		A      (  cls  :		str				, _A  :		Union[str, os.PathLike]				, **_A  :		List[Any]      )    ->							"PretrainedConfig":
								UpperCAmelCase_    ,      UpperCAmelCase_      :       Optional[Any]          =       cls.get_config_dict(_A				, **_A      )

								if config_dict.get('''model_type'''      ) == "bridgetower":
											UpperCAmelCase_      :       Optional[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(_A				, **_A      )






class  snake_case__      (					UpperCamelCase):
					a_        =					"bridgetower_text_model"




					def __init__(  self  :		Any				, _A  :		List[str]=5_02_65				, _A  :		Dict=7_68				, _A  :		Optional[int]=12				, _A  :		List[Any]=12				, _A  :		Optional[Any]=1				, _A  :		Union[str, Any]=30_72				, _A  :		List[Any]="gelu"				, _A  :		Optional[Any]=0.1				, _A  :		Optional[int]=0.1				, _A  :		List[str]=5_14				, _A  :		Dict=1				, _A  :		Optional[int]=1e-05				, _A  :		List[str]=1				, _A  :		str=0				, _A  :		Optional[int]=2				, _A  :		Tuple="absolute"				, _A  :		Tuple=True				, **_A  :		Optional[int]				, )    ->							List[Any]:
								super().__init__(**_A      )

								UpperCAmelCase_      :       List[str]          =       vocab_size
								UpperCAmelCase_      :       Optional[int]          =       hidden_size
								UpperCAmelCase_      :       Union[str, Any]          =       num_hidden_layers
								UpperCAmelCase_      :       Union[str, Any]          =       num_attention_heads
								UpperCAmelCase_      :       List[Any]          =       hidden_act
								UpperCAmelCase_      :       Any          =       initializer_factor
								UpperCAmelCase_      :       List[str]          =       intermediate_size
								UpperCAmelCase_      :       List[str]          =       hidden_dropout_prob
								UpperCAmelCase_      :       Optional[int]          =       attention_probs_dropout_prob
								UpperCAmelCase_      :       Union[str, Any]          =       max_position_embeddings
								UpperCAmelCase_      :       List[str]          =       type_vocab_size
								UpperCAmelCase_      :       List[str]          =       layer_norm_eps
								UpperCAmelCase_      :       List[str]          =       position_embedding_type
								UpperCAmelCase_      :       Optional[Any]          =       use_cache
								UpperCAmelCase_      :       Any          =       pad_token_id
								UpperCAmelCase_      :       List[str]          =       bos_token_id
								UpperCAmelCase_      :       str          =       eos_token_id





					@classmethod
					def 		A      (  cls  :		List[Any]				, _A  :		Union[str, os.PathLike]				, **_A  :		Optional[Any]      )    ->							"PretrainedConfig":
								UpperCAmelCase_    ,      UpperCAmelCase_      :       int          =       cls.get_config_dict(_A				, **_A      )

								if config_dict.get('''model_type'''      ) == "bridgetower":
											UpperCAmelCase_      :       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(_A				, **_A      )






class  snake_case__      (					UpperCamelCase):
					a_        =					"bridgetower"




					def __init__(  self  :		List[str]				, _A  :		Any=True				, _A  :		Optional[Any]="gelu"				, _A  :		Union[str, Any]=7_68				, _A  :		Optional[Any]=1				, _A  :		str=1e-05				, _A  :		List[str]=False				, _A  :		Tuple="add"				, _A  :		Union[str, Any]=12				, _A  :		Optional[int]=6				, _A  :		Any=False				, _A  :		int=False				, _A  :		int=None				, _A  :		Any=None				, **_A  :		Optional[Any]				, )    ->							List[Any]:
								# TODO: remove this once the Hub files are updated.
								UpperCAmelCase_      :       int          =       kwargs.pop('''text_config_dict'''				, _A      )
								UpperCAmelCase_      :       Optional[Any]          =       kwargs.pop('''vision_config_dict'''				, _A      )

								super().__init__(**_A      )
								UpperCAmelCase_      :       Optional[Any]          =       share_cross_modal_transformer_layers
								UpperCAmelCase_      :       int          =       hidden_act
								UpperCAmelCase_      :       List[Any]          =       hidden_size
								UpperCAmelCase_      :       Tuple          =       initializer_factor
								UpperCAmelCase_      :       List[Any]          =       layer_norm_eps
								UpperCAmelCase_      :       Union[str, Any]          =       share_link_tower_layers
								UpperCAmelCase_      :       List[str]          =       link_tower_type
								UpperCAmelCase_      :       Any          =       num_attention_heads
								UpperCAmelCase_      :       List[str]          =       num_hidden_layers
								UpperCAmelCase_      :       str          =       tie_word_embeddings
								UpperCAmelCase_      :       Dict          =       init_layernorm_from_vision_encoder

								if text_config is None:
											UpperCAmelCase_      :       Union[str, Any]          =       {}
											logger.info('''`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.'''      )

								if vision_config is None:
											UpperCAmelCase_      :       int          =       {}
											logger.info('''`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values.'''      )

								UpperCAmelCase_      :       Optional[int]          =       BridgeTowerTextConfig(**_A      )
								UpperCAmelCase_      :       List[str]          =       BridgeTowerVisionConfig(**_A      )




					@classmethod
					def 		A      (  cls  :		List[Any]				, _A  :		BridgeTowerTextConfig				, _A  :		BridgeTowerVisionConfig				, **_A  :		List[str]      )    ->							List[Any]:
								return cls(text_config=text_config.to_dict()				, vision_config=vision_config.to_dict()				, **_A      )





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










'''simple docstring'''





_UpperCamelCase						:						List[str]  =					[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)]
def __UpperCAmelCase   (					A					:			int		)    ->   int:
			UpperCAmelCase_      :       str          =       0
			while number:
						# Increased Speed Slightly by checking every 5 digits together.
						sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
						number //= 1_0_0_0_0_0

			return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
_UpperCamelCase						:						list[bool | None]  =					[None] * 10_000_000
_UpperCamelCase						:						List[str]  =					True
_UpperCamelCase						:						Tuple  =					False
def __UpperCAmelCase   (					A					:			int		)    ->   bool:

			if CHAINS[number - 1] is not None:
						return CHAINS[number - 1]  # type: ignore

			UpperCAmelCase_      :       Dict          =       chain(next_number(A		)		)
			UpperCAmelCase_      :       int          =       number_chain

			while number < 1_0_0_0_0_0_0_0:
						UpperCAmelCase_      :       Optional[Any]          =       number_chain
						number *= 1_0

			return number_chain
def __UpperCAmelCase   (					A					:			int = 1_0_0_0_0_0_0_0		)    ->   int:
			for i in range(1			,       A		):
						if CHAINS[i] is None:
									chain(i + 1		)

			return CHAINS[:number].count(A		)


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(f'''{solution() = }''')


