




"""simple docstring"""




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


lowerCAmelCase							:    Tuple  							=							logging.get_logger(__name__)

lowerCAmelCase							:    List[Any]  							=							{
    "salesforce/blip2-opt-2.7b": "https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json",
}






class 					__magic_name__							( UpperCAmelCase_       ):






				'''simple docstring'''
				__UpperCamelCase    						=		'blip_2_vision_model'





				def __init__( self	,				_a=1_408	,				_a=6_144	,				_a=39	,				_a=16	,				_a=224	,				_a=14	,				_a="gelu"	,				_a=0.00_001	,				_a=0.0	,				_a=1e-1_0	,				_a=True	,				**_a	,				):





							"""simple docstring"""
							super().__init__(**_lowercase				)

							lowerCamelCase       =      hidden_size
							lowerCamelCase       =      intermediate_size
							lowerCamelCase       =      num_hidden_layers
							lowerCamelCase       =      num_attention_heads
							lowerCamelCase       =      patch_size
							lowerCamelCase       =      image_size
							lowerCamelCase       =      initializer_range
							lowerCamelCase       =      attention_dropout
							lowerCamelCase       =      layer_norm_eps
							lowerCamelCase       =      hidden_act
							lowerCamelCase       =      qkv_bias





				@classmethod
				def      _lowerCAmelCase       ( cls	,				_a	,				**_a				):





							"""simple docstring"""
							cls._set_token_in_kwargs(_lowercase				)

							lowerCamelCase       =      cls.get_config_dict(_lowercase	,				**_lowercase				)

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






class 					__magic_name__							( UpperCAmelCase_       ):






				'''simple docstring'''
				__UpperCamelCase    						=		'blip_2_qformer'





				def __init__( self	,				_a=30_522	,				_a=768	,				_a=12	,				_a=12	,				_a=3_072	,				_a="gelu"	,				_a=0.1	,				_a=0.1	,				_a=512	,				_a=0.02	,				_a=1e-1_2	,				_a=0	,				_a="absolute"	,				_a=2	,				_a=1_408	,				**_a	,				):





							"""simple docstring"""
							super().__init__(pad_token_id=_lowercase	,				**_lowercase				)

							lowerCamelCase       =      vocab_size
							lowerCamelCase       =      hidden_size
							lowerCamelCase       =      num_hidden_layers
							lowerCamelCase       =      num_attention_heads
							lowerCamelCase       =      hidden_act
							lowerCamelCase       =      intermediate_size
							lowerCamelCase       =      hidden_dropout_prob
							lowerCamelCase       =      attention_probs_dropout_prob
							lowerCamelCase       =      max_position_embeddings
							lowerCamelCase       =      initializer_range
							lowerCamelCase       =      layer_norm_eps
							lowerCamelCase       =      position_embedding_type
							lowerCamelCase       =      cross_attention_frequency
							lowerCamelCase       =      encoder_hidden_size





				@classmethod
				def      _lowerCAmelCase       ( cls	,				_a	,				**_a				):





							"""simple docstring"""
							cls._set_token_in_kwargs(_lowercase				)

							lowerCamelCase       =      cls.get_config_dict(_lowercase	,				**_lowercase				)

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






class 					__magic_name__							( UpperCAmelCase_       ):






				'''simple docstring'''
				__UpperCamelCase    						=		'blip-2'
				__UpperCamelCase    						=		True





				def __init__( self	,				_a=None	,				_a=None	,				_a=None	,				_a=32	,				**_a				):





							"""simple docstring"""
							super().__init__(**_lowercase				)

							if vision_config is None:
										lowerCamelCase       =      {}
										logger.info("""vision_config is None. initializing the Blip2VisionConfig with default values."""				)

							if qformer_config is None:
										lowerCamelCase       =      {}
										logger.info("""qformer_config is None. Initializing the Blip2QFormerConfig with default values."""				)

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

							lowerCamelCase       =      BlipaVisionConfig(**_lowercase				)
							lowerCamelCase       =      BlipaQFormerConfig(**_lowercase				)
							lowerCamelCase       =      text_config['model_type'] if 'model_type' in text_config else 'opt'
							lowerCamelCase       =      CONFIG_MAPPING[text_model_type](**_lowercase				)

							lowerCamelCase       =      self.text_config.tie_word_embeddings
							lowerCamelCase       =      self.text_config.is_encoder_decoder

							lowerCamelCase       =      num_query_tokens
							lowerCamelCase       =      self.vision_config.hidden_size
							lowerCamelCase       =      self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
							lowerCamelCase       =      1.0
							lowerCamelCase       =      0.02





				@classmethod
				def      _lowerCAmelCase       ( cls	,				_a	,				_a	,				_a	,				**_a	,				):





							"""simple docstring"""
							return cls(
							    vision_config=vision_config.to_dict()	,				qformer_config=qformer_config.to_dict()	,				text_config=text_config.to_dict()	,				**_lowercase	,				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      copy.deepcopy(self.__dict__				)
							lowerCamelCase       =      self.vision_config.to_dict()
							lowerCamelCase       =      self.qformer_config.to_dict()
							lowerCamelCase       =      self.text_config.to_dict()
							lowerCamelCase       =      self.__class__.model_type
							return output









"""simple docstring"""




from functools import lru_cache



def 					a__				(       snake_case__       )		->      set:
			lowerCamelCase       =      2
			lowerCamelCase       =      set()
			while i * i <= n:
						if n % i:
									i += 1
						else:
									n //= i
									factors.add(snake_case__       )
			if n > 1:
						factors.add(snake_case__       )
			return factors



@lru_cache
def 					a__				(       snake_case__       )		->      int:
			return len(unique_prime_factors(snake_case__       )       )



def 					a__				(       snake_case__       )		->      bool:
			return len(set(snake_case__       )       ) in (0, 1)



def 					a__				(       snake_case__       )		->      list:
			lowerCamelCase       =      2

			while True:
						# Increment each value of a generated range
						lowerCamelCase       =      [base + i for i in range(snake_case__       )]

						# Run elements through out unique_prime_factors function
						# Append our target number to the end.
						lowerCamelCase       =      [upf_len(snake_case__       ) for x in group]
						checker.append(snake_case__       )

						# If all numbers in the list are equal, return the group variable.
						if equality(snake_case__       ):
									return group

						# Increment our base variable by 1
						base += 1



def 					a__				(       snake_case__ = 4       )		->      int:
			lowerCamelCase       =      run(snake_case__       )
			return results[0] if len(snake_case__       ) else None


if __name__ == "__main__":
					print(solution())



