





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


_A					:				Dict				=			logging.get_logger(__name__)

_A					:				str				=			{
    'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json',
}



class 					__snake_case	(  __SCREAMING_SNAKE_CASE    ):


    '''simple docstring'''







    lowerCamelCase__    :		str				=	"""switch_transformers"""
    lowerCamelCase__    :		str				=	["""past_key_values"""]
    lowerCamelCase__    :		List[str]				=	{"""hidden_size""": """d_model""", """num_attention_heads""": """num_heads""", """num_hidden_layers""": """num_layers"""}



    def __init__(       self   ,				A_=3_21_28   ,				A_=7_68   ,				A_=64   ,				A_=20_48   ,				A_=64   ,				A_=12   ,				A_=3   ,				A_=12   ,				A_=3   ,				A_=12   ,				A_=8   ,				A_=False   ,				A_=0.01   ,				A_="float32"   ,				A_=False   ,				A_=32   ,				A_=1_28   ,				A_=0.1   ,				A_=1E-6   ,				A_=0.001   ,				A_=0.001   ,				A_=1.0   ,				A_="relu"   ,				A_=True   ,				A_=False   ,				A_=True   ,				A_=0   ,				A_=1   ,				**A_   ,				):





        '''simple docstring'''

        SCREAMING_SNAKE_CASE__											=			vocab_size
        SCREAMING_SNAKE_CASE__											=			d_model
        SCREAMING_SNAKE_CASE__											=			d_kv
        SCREAMING_SNAKE_CASE__											=			d_ff

        SCREAMING_SNAKE_CASE__											=			num_sparse_encoder_layers

        SCREAMING_SNAKE_CASE__											=			num_layers
        SCREAMING_SNAKE_CASE__											=			(
            num_decoder_layers if num_decoder_layers is not None else self.num_layers
        )  # default = symmetry
        SCREAMING_SNAKE_CASE__											=			num_sparse_decoder_layers

        # This tells us, each how many encoder layer we'll have to set a sparse layer.
        if self.num_sparse_encoder_layers > 0:
            SCREAMING_SNAKE_CASE__											=			self.num_layers // self.num_sparse_encoder_layers
        else:
            SCREAMING_SNAKE_CASE__											=			self.num_layers  # HACK: this will create 0 sparse layers

        # This tells us, each how many encoder layer we'll have to set a sparse layer.
        if self.num_sparse_decoder_layers > 0:
            SCREAMING_SNAKE_CASE__											=			self.num_decoder_layers // self.num_sparse_decoder_layers
        else:
            SCREAMING_SNAKE_CASE__											=			self.num_decoder_layers  # HACK: this will create 0 sparse layers

        SCREAMING_SNAKE_CASE__											=			num_heads
        SCREAMING_SNAKE_CASE__											=			num_experts
        SCREAMING_SNAKE_CASE__											=			expert_capacity
        SCREAMING_SNAKE_CASE__											=			router_bias
        SCREAMING_SNAKE_CASE__											=			router_jitter_noise
        if router_dtype not in ["float32", "float16", "bfloat16"]:
            raise ValueError(f'''`router_dtype` must be one of \'float32\', \'float16\' or \'bfloat16\', got {router_dtype}'''     )
        SCREAMING_SNAKE_CASE__											=			router_dtype

        SCREAMING_SNAKE_CASE__											=			router_ignore_padding_tokens
        SCREAMING_SNAKE_CASE__											=			relative_attention_num_buckets
        SCREAMING_SNAKE_CASE__											=			relative_attention_max_distance

        SCREAMING_SNAKE_CASE__											=			dropout_rate
        SCREAMING_SNAKE_CASE__											=			layer_norm_epsilon
        SCREAMING_SNAKE_CASE__											=			initializer_factor
        SCREAMING_SNAKE_CASE__											=			feed_forward_proj
        SCREAMING_SNAKE_CASE__											=			use_cache
        SCREAMING_SNAKE_CASE__											=			add_router_probs

        SCREAMING_SNAKE_CASE__											=			router_z_loss_coef
        SCREAMING_SNAKE_CASE__											=			router_aux_loss_coef

        SCREAMING_SNAKE_CASE__											=			self.feed_forward_proj.split('''-'''     )
        SCREAMING_SNAKE_CASE__											=			act_info[-1]
        SCREAMING_SNAKE_CASE__											=			act_info[0] == "gated"

        if len(_SCREAMING_SNAKE_CASE     ) > 1 and act_info[0] != "gated" or len(_SCREAMING_SNAKE_CASE     ) > 2:
            raise ValueError(
                f'''`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer.'''
                '''Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. '''
                '''\'gated-gelu\' or \'relu\''''     )

        # for backwards compatibility
        if feed_forward_proj == "gated-gelu":
            SCREAMING_SNAKE_CASE__											=			"gelu_new"

        super().__init__(
            pad_token_id=_SCREAMING_SNAKE_CASE   ,				eos_token_id=_SCREAMING_SNAKE_CASE   ,				is_encoder_decoder=_SCREAMING_SNAKE_CASE   ,				**_SCREAMING_SNAKE_CASE   ,				)





"""simple docstring"""






import copy
import os
from typing import Union

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


__snake_case				:  str =       logging.get_logger(__name__)

__snake_case				:  Union[str, Any] =       {
    'microsoft/git-base': 'https://huggingface.co/microsoft/git-base/resolve/main/config.json',
}



class      A__  (    __SCREAMING_SNAKE_CASE				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      'git_vision_model'

	def __init__(	self:						Optional[int]			,     _SCREAMING_SNAKE_CASE:						List[Any]=768			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=3072			,     _SCREAMING_SNAKE_CASE:						str=12			,     _SCREAMING_SNAKE_CASE:						Any=12			,     _SCREAMING_SNAKE_CASE:						Dict=3			,     _SCREAMING_SNAKE_CASE:						List[Any]=224			,     _SCREAMING_SNAKE_CASE:						List[str]=16			,     _SCREAMING_SNAKE_CASE:						str="quick_gelu"			,     _SCREAMING_SNAKE_CASE:						Any=1e-5			,     _SCREAMING_SNAKE_CASE:						List[str]=0.0			,     _SCREAMING_SNAKE_CASE:						Dict=0.02			,     **_SCREAMING_SNAKE_CASE:						str			,     )							->			Optional[Any]:

				"""simple docstring"""

				super().__init__(**_SCREAMING_SNAKE_CASE)

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







	@classmethod
	def 				_SCREAMING_SNAKE_CASE  (	cls:						Dict			,     _SCREAMING_SNAKE_CASE:						Union[str, os.PathLike]			,     **_SCREAMING_SNAKE_CASE:						Dict)							->			"PretrainedConfig":

				"""simple docstring"""

				cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE)

				__lowerCAmelCase		,      __lowerCAmelCase :    List[Any]				=			cls.get_config_dict(_SCREAMING_SNAKE_CASE			,     **_SCREAMING_SNAKE_CASE)

				# get the vision config dict if we are loading from GITConfig
				if config_dict.get("model_type") == "git":
							__lowerCAmelCase :    str				=			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(_SCREAMING_SNAKE_CASE			,     **_SCREAMING_SNAKE_CASE)






class      A__  (    __SCREAMING_SNAKE_CASE				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      'git'

	def __init__(	self:						Union[str, Any]			,     _SCREAMING_SNAKE_CASE:						Tuple=None			,     _SCREAMING_SNAKE_CASE:						Dict=3_0522			,     _SCREAMING_SNAKE_CASE:						Any=768			,     _SCREAMING_SNAKE_CASE:						str=6			,     _SCREAMING_SNAKE_CASE:						int=12			,     _SCREAMING_SNAKE_CASE:						Dict=3072			,     _SCREAMING_SNAKE_CASE:						Optional[Any]="gelu"			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=0.1			,     _SCREAMING_SNAKE_CASE:						Any=0.1			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=1024			,     _SCREAMING_SNAKE_CASE:						str=0.02			,     _SCREAMING_SNAKE_CASE:						Tuple=1e-12			,     _SCREAMING_SNAKE_CASE:						List[str]=0			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]="absolute"			,     _SCREAMING_SNAKE_CASE:						Union[str, Any]=True			,     _SCREAMING_SNAKE_CASE:						Tuple=False			,     _SCREAMING_SNAKE_CASE:						Dict=101			,     _SCREAMING_SNAKE_CASE:						Tuple=102			,     _SCREAMING_SNAKE_CASE:						Any=None			,     **_SCREAMING_SNAKE_CASE:						List[Any]			,     )							->			List[Any]:

				"""simple docstring"""

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

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

				__lowerCAmelCase :    List[str]				=			GitVisionConfig(**_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase :    List[Any]				=			vocab_size
				__lowerCAmelCase :    int				=			hidden_size
				__lowerCAmelCase :    Dict				=			num_hidden_layers
				__lowerCAmelCase :    Tuple				=			num_attention_heads
				__lowerCAmelCase :    Union[str, Any]				=			hidden_act
				__lowerCAmelCase :    Dict				=			intermediate_size
				__lowerCAmelCase :    List[str]				=			hidden_dropout_prob
				__lowerCAmelCase :    Union[str, Any]				=			attention_probs_dropout_prob
				__lowerCAmelCase :    Union[str, Any]				=			max_position_embeddings
				__lowerCAmelCase :    Optional[int]				=			initializer_range
				__lowerCAmelCase :    str				=			layer_norm_eps
				__lowerCAmelCase :    Optional[Any]				=			position_embedding_type
				__lowerCAmelCase :    str				=			use_cache
				__lowerCAmelCase :    str				=			tie_word_embeddings
				__lowerCAmelCase :    Optional[int]				=			num_image_with_embedding

				__lowerCAmelCase :    Optional[Any]				=			bos_token_id
				__lowerCAmelCase :    Any				=			eos_token_id







	def 				_SCREAMING_SNAKE_CASE  (	self:						Dict)							->			List[str]:

				"""simple docstring"""

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