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


__lowerCAmelCase					   =       logging.get_logger(__name__)

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





class     lowerCamelCase      (       __lowerCamelCase					):
	UpperCamelCase_  :					Any    		=	'switch_transformers'
	UpperCamelCase_  :					Optional[Any]    		=	['past_key_values']
	UpperCamelCase_  :					Dict    		=	{'hidden_size': 'd_model', 'num_attention_heads': 'num_heads', 'num_hidden_layers': 'num_layers'}







	def __init__(     self      :Union[str, Any]   ,     lowercase      :Union[str, Any]=3_2_1_2_8   ,     lowercase      :Dict=7_6_8   ,     lowercase      :Any=6_4   ,     lowercase      :Optional[Any]=2_0_4_8   ,     lowercase      :List[Any]=6_4   ,     lowercase      :Optional[Any]=1_2   ,     lowercase      :List[Any]=3   ,     lowercase      :Any=1_2   ,     lowercase      :Optional[int]=3   ,     lowercase      :List[str]=1_2   ,     lowercase      :Optional[Any]=8   ,     lowercase      :Dict=False   ,     lowercase      :str=0.01   ,     lowercase      :List[Any]="float32"   ,     lowercase      :Union[str, Any]=False   ,     lowercase      :Any=3_2   ,     lowercase      :int=1_2_8   ,     lowercase      :Tuple=0.1   ,     lowercase      :List[str]=1e-6   ,     lowercase      :Union[str, Any]=0.0_01   ,     lowercase      :Dict=0.0_01   ,     lowercase      :Optional[Any]=1.0   ,     lowercase      :Optional[Any]="relu"   ,     lowercase      :Union[str, Any]=True   ,     lowercase      :str=False   ,     lowercase      :Optional[Any]=True   ,     lowercase      :Any=0   ,     lowercase      :Union[str, Any]=1   ,     **lowercase      :Optional[Any]   ,     )		->      List[str]:







				"""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(lowercase			) > 1 and act_info[0] != "gated" or len(lowercase			) > 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=lowercase   ,     eos_token_id=lowercase   ,     is_encoder_decoder=lowercase   ,     **lowercase   ,     )

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCAmelCase					   =       {
    'configuration_deberta': ['DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DebertaConfig', 'DebertaOnnxConfig'],
    'tokenization_deberta': ['DebertaTokenizer'],
}

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__lowerCAmelCase					   =       ['DebertaTokenizerFast']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__lowerCAmelCase					   =       [
							    'DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'DebertaForMaskedLM',
							    'DebertaForQuestionAnswering',
							    'DebertaForSequenceClassification',
							    'DebertaForTokenClassification',
							    'DebertaModel',
							    'DebertaPreTrainedModel',
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__lowerCAmelCase					   =       [
							    'TF_DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'TFDebertaForMaskedLM',
							    'TFDebertaForQuestionAnswering',
							    'TFDebertaForSequenceClassification',
							    'TFDebertaForTokenClassification',
							    'TFDebertaModel',
							    'TFDebertaPreTrainedModel',
							]


if TYPE_CHECKING:
							from .configuration_deberta import DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, DebertaConfig, DebertaOnnxConfig
							from .tokenization_deberta import DebertaTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_deberta_fast import DebertaTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_deberta import (
														    DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
														    DebertaForMaskedLM,
														    DebertaForQuestionAnswering,
														    DebertaForSequenceClassification,
														    DebertaForTokenClassification,
														    DebertaModel,
														    DebertaPreTrainedModel,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_deberta import (
														    TF_DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TFDebertaForMaskedLM,
														    TFDebertaForQuestionAnswering,
														    TFDebertaForSequenceClassification,
														    TFDebertaForTokenClassification,
														    TFDebertaModel,
														    TFDebertaPreTrainedModel,
														)


else:
							import sys

							__lowerCAmelCase					   =       _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)