


"""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__      				=   logging.get_logger(__name__)

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


class       SCREAMING_SNAKE_CASE__				(		lowercase				):
       """simple docstring"""


       a  :				Any   ="blip_2_vision_model"

       def __init__(						self		,     snake_case__=1_408		,     snake_case__=6_144		,     snake_case__=39		,     snake_case__=16		,     snake_case__=224		,     snake_case__=14		,     snake_case__="gelu"		,     snake_case__=0.00001		,     snake_case__=0.0		,     snake_case__=1e-10		,     snake_case__=True		,     **snake_case__		,     ):






         """simple docstring"""





         super().__init__(**snake_case__						)

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







       @classmethod
       def        lowercase__							(						cls		,     snake_case__		,     **snake_case__						):






         """simple docstring"""





         cls._set_token_in_kwargs(snake_case__						)

         lowerCAmelCase						,  lowerCAmelCase     :     Dict								=							cls.get_config_dict(snake_case__		,     **snake_case__						)

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


class       SCREAMING_SNAKE_CASE__				(		lowercase				):
       """simple docstring"""


       a  :				List[str]   ="blip_2_qformer"

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






         """simple docstring"""





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

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







       @classmethod
       def        lowercase__							(						cls		,     snake_case__		,     **snake_case__						):






         """simple docstring"""





         cls._set_token_in_kwargs(snake_case__						)

         lowerCAmelCase						,  lowerCAmelCase     :     Dict								=							cls.get_config_dict(snake_case__		,     **snake_case__						)

         # get the qformer config dict if we are loading from Blip2Config
         if config_dict.get("model_type"						) == "blip-2":
           lowerCAmelCase     :     Union[str, Any]								=							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(snake_case__		,     **snake_case__						)


class       SCREAMING_SNAKE_CASE__				(		lowercase				):
       """simple docstring"""


       a  :				List[Any]   ="blip-2"
       a  :				str   =True

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






         """simple docstring"""





         super().__init__(**snake_case__						)

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

         if qformer_config is None:
           lowerCAmelCase     :     Optional[int]								=							{}
           logger.info("qformer_config is None. Initializing the Blip2QFormerConfig with default values."						)

         if text_config is None:
           lowerCAmelCase     :     Union[str, Any]								=							{}
           logger.info("text_config is None. Initializing the text config with default values (`OPTConfig`)."						)

         lowerCAmelCase     :     Union[str, Any]								=							BlipaVisionConfig(**snake_case__						)
         lowerCAmelCase     :     Union[str, Any]								=							BlipaQFormerConfig(**snake_case__						)
         lowerCAmelCase     :     Optional[Any]								=							text_config["model_type"] if "model_type" in text_config else "opt"
         lowerCAmelCase     :     str								=							CONFIG_MAPPING[text_model_type](**snake_case__						)

         lowerCAmelCase     :     str								=							self.text_config.tie_word_embeddings
         lowerCAmelCase     :     int								=							self.text_config.is_encoder_decoder

         lowerCAmelCase     :     str								=							num_query_tokens
         lowerCAmelCase     :     str								=							self.vision_config.hidden_size
         lowerCAmelCase     :     Tuple								=							self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
         lowerCAmelCase     :     Optional[int]								=							1.0
         lowerCAmelCase     :     Optional[Any]								=							0.02

       @classmethod
       def        lowercase__							(						cls		,     snake_case__		,     snake_case__		,     snake_case__		,     **snake_case__		,     ):






         """simple docstring"""





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







       def        lowercase__							(						self						):






         """simple docstring"""





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









"""simple docstring"""







def 					a__			(				SCREAMING_SNAKE_CASE    :    int				,      SCREAMING_SNAKE_CASE    :    int				):


  '''simple docstring'''







  while b:
    lowerCAmelCase						,  lowerCAmelCase     :     Any								=							b, a % b
  return a
def 					a__			(				SCREAMING_SNAKE_CASE    :    int				,      SCREAMING_SNAKE_CASE    :    int				):


  '''simple docstring'''







  return a if b == 0 else euclidean_gcd_recursive(SCREAMING_SNAKE_CASE				,      a % b				)
def 					a__			(				):


  '''simple docstring'''







  print(f"""euclidean_gcd(3, 5) = {euclidean_gcd(3				,      5				)}"""				)
  print(f"""euclidean_gcd(5, 3) = {euclidean_gcd(5				,      3				)}"""				)
  print(f"""euclidean_gcd(1, 3) = {euclidean_gcd(1				,      3				)}"""				)
  print(f"""euclidean_gcd(3, 6) = {euclidean_gcd(3				,      6				)}"""				)
  print(f"""euclidean_gcd(6, 3) = {euclidean_gcd(6				,      3				)}"""				)

  print(f"""euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3				,      5				)}"""				)
  print(f"""euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5				,      3				)}"""				)
  print(f"""euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1				,      3				)}"""				)
  print(f"""euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3				,      6				)}"""				)
  print(f"""euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6				,      3				)}"""				)


if __name__ == "__main__":
     main()





