


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


__magic_name__			=      logging.get_logger(__name__)

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



class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""blip_2_vision_model"""






  def __init__(							self :       List[str]	,_a :       List[str]=1408	,_a :       str=6144	,_a :       int=39	,_a :       Tuple=16	,_a :       str=224	,_a :       Optional[Any]=14	,_a :       Tuple="gelu"	,_a :       Dict=0.00001	,_a :       str=0.0	,_a :       Optional[Any]=1e-10	,_a :       Tuple=True	,**_a :       List[Any]	,):

        '''simple docstring'''




        super().__init__(**_a )

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






  @classmethod
  def        _a							(							cls :       int	,_a :       Union[str, os.PathLike]	,**_a :       Any ):

        '''simple docstring'''




        cls._set_token_in_kwargs(_a )

        A_   ,					A_						:  str          =				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_						:  Tuple          =				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		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""blip_2_qformer"""






  def __init__(							self :       List[str]	,_a :       List[Any]=30522	,_a :       Any=768	,_a :       str=12	,_a :       str=12	,_a :       Any=3072	,_a :       Any="gelu"	,_a :       Optional[int]=0.1	,_a :       List[str]=0.1	,_a :       Tuple=512	,_a :       List[str]=0.02	,_a :       Union[str, Any]=1e-12	,_a :       Optional[Any]=0	,_a :       Tuple="absolute"	,_a :       Union[str, Any]=2	,_a :       Union[str, Any]=1408	,**_a :       int	,):

        '''simple docstring'''




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

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






  @classmethod
  def        _a							(							cls :       Optional[Any]	,_a :       Union[str, os.PathLike]	,**_a :       Tuple ):

        '''simple docstring'''




        cls._set_token_in_kwargs(_a )

        A_   ,					A_						:  Any          =				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_						:  Tuple          =				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		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""blip-2"""
  a_  					=							True






  def __init__(							self :       str	,_a :       Union[str, Any]=None	,_a :       Any=None	,_a :       str=None	,_a :       List[str]=32	,**_a :       Union[str, Any] ):

        '''simple docstring'''




        super().__init__(**_a )

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

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

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

        A_						:  Tuple          =				BlipaVisionConfig(**_a )
        A_						:  str          =				BlipaQFormerConfig(**_a )
        A_						:  List[Any]          =				text_config["""model_type"""] if """model_type""" in text_config else """opt"""
        A_						:  Dict          =				CONFIG_MAPPING[text_model_type](**_a )

        A_						:  Union[str, Any]          =				self.text_config.tie_word_embeddings
        A_						:  int          =				self.text_config.is_encoder_decoder

        A_						:  Optional[int]          =				num_query_tokens
        A_						:  List[Any]          =				self.vision_config.hidden_size
        A_						:  Optional[Any]          =				self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
        A_						:  List[Any]          =				1.0
        A_						:  Optional[int]          =				0.02






  @classmethod
  def        _a							(							cls :       List[Any]	,_a :       BlipaVisionConfig	,_a :       BlipaQFormerConfig	,_a :       PretrainedConfig	,**_a :       Tuple	,):

        '''simple docstring'''




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






  def        _a							(							self :       Union[str, Any] ):

        '''simple docstring'''




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




'''simple docstring'''


from ... import PretrainedConfig


__magic_name__			=      {
    'sijunhe/nezha-cn-base': 'https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json',
}



class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP
  a_  					=							"""nezha"""






  def __init__(							self :       int	,_a :       Union[str, Any]=21128	,_a :       int=768	,_a :       Any=12	,_a :       List[str]=12	,_a :       str=3072	,_a :       int="gelu"	,_a :       int=0.1	,_a :       str=0.1	,_a :       Tuple=512	,_a :       List[Any]=64	,_a :       Dict=2	,_a :       List[Any]=0.02	,_a :       Optional[Any]=1e-12	,_a :       List[Any]=0.1	,_a :       Union[str, Any]=0	,_a :       Any=2	,_a :       Union[str, Any]=3	,_a :       int=True	,**_a :       int	,):

        '''simple docstring'''




        super().__init__(pad_token_id=_a	,bos_token_id=_a	,eos_token_id=_a	,**_a )

        A_						:  Tuple          =				vocab_size
        A_						:  int          =				hidden_size
        A_						:  Any          =				num_hidden_layers
        A_						:  List[Any]          =				num_attention_heads
        A_						:  Tuple          =				hidden_act
        A_						:  List[Any]          =				intermediate_size
        A_						:  List[str]          =				hidden_dropout_prob
        A_						:  Tuple          =				attention_probs_dropout_prob
        A_						:  Dict          =				max_position_embeddings
        A_						:  Optional[Any]          =				max_relative_position
        A_						:  List[Any]          =				type_vocab_size
        A_						:  int          =				initializer_range
        A_						:  Tuple          =				layer_norm_eps
        A_						:  Dict          =				classifier_dropout
        A_						:  int          =				use_cache
