


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


__UpperCamelCase     		=							logging.get_logger(__name__)

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







class 							lowerCamelCase__						(				UpperCAmelCase   ):






			"""simple docstring"""






			_UpperCamelCase		:       List[str] 			=		'switch_transformers'
			_UpperCamelCase		:       Optional[int] 			=		['past_key_values']
			_UpperCamelCase		:       Optional[int] 			=		{'hidden_size': 'd_model', 'num_attention_heads': 'num_heads', 'num_hidden_layers': 'num_layers'}




			def __init__(				self   ,    snake_case=32128   ,    snake_case=768   ,    snake_case=64   ,    snake_case=2048   ,    snake_case=64   ,    snake_case=12   ,    snake_case=3   ,    snake_case=12   ,    snake_case=3   ,    snake_case=12   ,    snake_case=8   ,    snake_case=False   ,    snake_case=0.01   ,    snake_case="float32"   ,    snake_case=False   ,    snake_case=32   ,    snake_case=128   ,    snake_case=0.1   ,    snake_case=1E-6   ,    snake_case=0.001   ,    snake_case=0.001   ,    snake_case=1.0   ,    snake_case="relu"   ,    snake_case=True   ,    snake_case=False   ,    snake_case=True   ,    snake_case=0   ,    snake_case=1   ,    **snake_case   ,    ):

						'''simple docstring'''


						UpperCamelCase__       =							vocab_size
						UpperCamelCase__       =							d_model
						UpperCamelCase__       =							d_kv
						UpperCamelCase__       =							d_ff

						UpperCamelCase__       =							num_sparse_encoder_layers

						UpperCamelCase__       =							num_layers
						UpperCamelCase__       =							(
						    num_decoder_layers if num_decoder_layers is not None else self.num_layers
						)  # default = symmetry
						UpperCamelCase__       =							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:
									UpperCamelCase__       =							self.num_layers // self.num_sparse_encoder_layers
						else:
									UpperCamelCase__       =							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:
									UpperCamelCase__       =							self.num_decoder_layers // self.num_sparse_decoder_layers
						else:
									UpperCamelCase__       =							self.num_decoder_layers  # HACK: this will create 0 sparse layers

						UpperCamelCase__       =							num_heads
						UpperCamelCase__       =							num_experts
						UpperCamelCase__       =							expert_capacity
						UpperCamelCase__       =							router_bias
						UpperCamelCase__       =							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}'''  )
						UpperCamelCase__       =							router_dtype

						UpperCamelCase__       =							router_ignore_padding_tokens
						UpperCamelCase__       =							relative_attention_num_buckets
						UpperCamelCase__       =							relative_attention_max_distance

						UpperCamelCase__       =							dropout_rate
						UpperCamelCase__       =							layer_norm_epsilon
						UpperCamelCase__       =							initializer_factor
						UpperCamelCase__       =							feed_forward_proj
						UpperCamelCase__       =							use_cache
						UpperCamelCase__       =							add_router_probs

						UpperCamelCase__       =							router_z_loss_coef
						UpperCamelCase__       =							router_aux_loss_coef

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

						if len(snake_case  ) > 1 and act_info[0] != "gated" or len(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":
									UpperCamelCase__       =							"gelu_new"

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






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__UpperCamelCase     		=							{
    'configuration_xlm_roberta_xl': [
        'XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'XLMRobertaXLConfig',
        'XLMRobertaXLOnnxConfig',
    ],
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__UpperCamelCase     		=							[
						    'XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST',
						    'XLMRobertaXLForCausalLM',
						    'XLMRobertaXLForMaskedLM',
						    'XLMRobertaXLForMultipleChoice',
						    'XLMRobertaXLForQuestionAnswering',
						    'XLMRobertaXLForSequenceClassification',
						    'XLMRobertaXLForTokenClassification',
						    'XLMRobertaXLModel',
						    'XLMRobertaXLPreTrainedModel',
						]

if TYPE_CHECKING:
						from .configuration_xlm_roberta_xl import (
						    XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    XLMRobertaXLConfig,
						    XLMRobertaXLOnnxConfig,
						)

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_xlm_roberta_xl import (
												    XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
												    XLMRobertaXLForCausalLM,
												    XLMRobertaXLForMaskedLM,
												    XLMRobertaXLForMultipleChoice,
												    XLMRobertaXLForQuestionAnswering,
												    XLMRobertaXLForSequenceClassification,
												    XLMRobertaXLForTokenClassification,
												    XLMRobertaXLModel,
												    XLMRobertaXLPreTrainedModel,
												)

else:
						import sys

						__UpperCamelCase     		=							_LazyModule(__name__, globals()['__file__'], _import_structure)


