


"""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


UpperCAmelCase__					=logging.get_logger(__name__)

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





class  lowerCamelCase__    (		_a     ):
      a			:  Optional[int]           =		"""blip_2_vision_model"""
      def __init__(		self						:						int   ,							A_						:						Any=1_4_0_8   ,							A_						:						Any=6_1_4_4   ,							A_						:						Union[str, Any]=3_9   ,							A_						:						Any=1_6   ,							A_						:						Tuple=2_2_4   ,							A_						:						Union[str, Any]=1_4   ,							A_						:						Any="gelu"   ,							A_						:						List[str]=0.0_00_01   ,							A_						:						int=0.0   ,							A_						:						Optional[int]=1e-1_0   ,							A_						:						List[Any]=True   ,							**A_						:						List[str]   ,							):






       '''simple docstring'''


       super().__init__(**A_				)

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






      @classmethod
      def SCREAMING_SNAKE_CASE_						(		cls						:						Tuple   ,							A_						:						Union[str, os.PathLike]   ,							**A_						:						Tuple				):






       '''simple docstring'''


       cls._set_token_in_kwargs(A_				)

       __lowercase				,		__lowercase						=						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":
        __lowercase						=						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  lowerCamelCase__    (		_a     ):
      a			:  Optional[int]           =		"""blip_2_qformer"""
      def __init__(		self						:						Union[str, Any]   ,							A_						:						Union[str, Any]=3_0_5_2_2   ,							A_						:						Optional[int]=7_6_8   ,							A_						:						Dict=1_2   ,							A_						:						Dict=1_2   ,							A_						:						Union[str, Any]=3_0_7_2   ,							A_						:						int="gelu"   ,							A_						:						List[Any]=0.1   ,							A_						:						Tuple=0.1   ,							A_						:						Union[str, Any]=5_1_2   ,							A_						:						str=0.02   ,							A_						:						Optional[Any]=1e-1_2   ,							A_						:						Tuple=0   ,							A_						:						str="absolute"   ,							A_						:						List[Any]=2   ,							A_						:						Any=1_4_0_8   ,							**A_						:						Dict   ,							):






       '''simple docstring'''


       super().__init__(pad_token_id=A_   ,							**A_				)

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






      @classmethod
      def SCREAMING_SNAKE_CASE_						(		cls						:						Union[str, Any]   ,							A_						:						Union[str, os.PathLike]   ,							**A_						:						Dict				):






       '''simple docstring'''


       cls._set_token_in_kwargs(A_				)

       __lowercase				,		__lowercase						=						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":
        __lowercase						=						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  lowerCamelCase__    (		_a     ):
      a			:  Union[str, Any]           =		"""blip-2"""
      a			:  Any           =		True
      def __init__(		self						:						str   ,							A_						:						str=None   ,							A_						:						Tuple=None   ,							A_						:						str=None   ,							A_						:						int=3_2   ,							**A_						:						Union[str, Any]				):






       '''simple docstring'''


       super().__init__(**A_				)

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

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

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

       __lowercase						=						BlipaVisionConfig(**A_				)
       __lowercase						=						BlipaQFormerConfig(**A_				)
       __lowercase						=						text_config["""model_type"""] if """model_type""" in text_config else """opt"""
       __lowercase						=						CONFIG_MAPPING[text_model_type](**A_				)

       __lowercase						=						self.text_config.tie_word_embeddings
       __lowercase						=						self.text_config.is_encoder_decoder

       __lowercase						=						num_query_tokens
       __lowercase						=						self.vision_config.hidden_size
       __lowercase						=						self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
       __lowercase						=						1.0
       __lowercase						=						0.02
      @classmethod
      def SCREAMING_SNAKE_CASE_						(		cls						:						List[str]   ,							A_						:						BlipaVisionConfig   ,							A_						:						BlipaQFormerConfig   ,							A_						:						PretrainedConfig   ,							**A_						:						str   ,							):






       '''simple docstring'''


       return cls(
           vision_config=vision_config.to_dict()   ,							qformer_config=qformer_config.to_dict()   ,							text_config=text_config.to_dict()   ,							**A_   ,							)






      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]				):






       '''simple docstring'''


       __lowercase						=						copy.deepcopy(self.__dict__				)
       __lowercase						=						self.vision_config.to_dict()
       __lowercase						=						self.qformer_config.to_dict()
       __lowercase						=						self.text_config.to_dict()
       __lowercase						=						self.__class__.model_type
       return output




"""simple docstring"""

def lowerCAmelCase_   (					UpperCamelCase__						:			int					, UpperCamelCase__						:			int			):






 """simple docstring"""







 return x if y == 0 else greatest_common_divisor(UpperCamelCase__					, x % y			)


def lowerCAmelCase_   (					UpperCamelCase__						:			int					, UpperCamelCase__						:			int			):






 """simple docstring"""







 return (x * y) // greatest_common_divisor(UpperCamelCase__					, UpperCamelCase__			)


def lowerCAmelCase_   (					UpperCamelCase__						:			int = 20			):






 """simple docstring"""







 __lowercase						=						1
 for i in range(1					, n + 1			):
  __lowercase						=						lcm(UpperCamelCase__					, UpperCamelCase__			)
 return g


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