

'''simple docstring'''





import warnings

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


UpperCamelCase_    						=       logging.get_logger(__name__)

UpperCamelCase_    						=       {
    """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/config.json""",
    """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/config.json""",
}





class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):
				lowerCamelCase_		       =    'xlnet'
				lowerCamelCase_		       =    ['mems']
				lowerCamelCase_		       =    {
				    'n_token': 'vocab_size',  # Backward compatibility
				    'hidden_size': 'd_model',
				    'num_attention_heads': 'n_head',
				    'num_hidden_layers': 'n_layer',
				}







				def __init__(       self     :		Tuple		,					UpperCAmelCase__     :		Any=32000		,					UpperCAmelCase__     :		Union[str, Any]=1024		,					UpperCAmelCase__     :		Optional[Any]=24		,					UpperCAmelCase__     :		Any=16		,					UpperCAmelCase__     :		Optional[int]=4096		,					UpperCAmelCase__     :		Dict="gelu"		,					UpperCAmelCase__     :		List[Any]=True		,					UpperCAmelCase__     :		int="bi"		,					UpperCAmelCase__     :		Tuple=0.02		,					UpperCAmelCase__     :		Union[str, Any]=1E-12		,					UpperCAmelCase__     :		List[str]=0.1		,					UpperCAmelCase__     :		Optional[int]=512		,					UpperCAmelCase__     :		Tuple=None		,					UpperCAmelCase__     :		Any=True		,					UpperCAmelCase__     :		Optional[int]=False		,					UpperCAmelCase__     :		Dict=False		,					UpperCAmelCase__     :		Union[str, Any]=-1		,					UpperCAmelCase__     :		Optional[int]=False		,					UpperCAmelCase__     :		Optional[Any]="last"		,					UpperCAmelCase__     :		List[Any]=True		,					UpperCAmelCase__     :		str="tanh"		,					UpperCAmelCase__     :		Union[str, Any]=0.1		,					UpperCAmelCase__     :		Dict=5		,					UpperCAmelCase__     :		List[str]=5		,					UpperCAmelCase__     :		List[Any]=5		,					UpperCAmelCase__     :		Optional[int]=1		,					UpperCAmelCase__     :		List[Any]=2		,					**UpperCAmelCase__     :		str		,					):
										'''simple docstring'''
										lowercase :							Union[str, Any]    		=vocab_size
										lowercase :							List[Any]    		=d_model
										lowercase :							Union[str, Any]    		=n_layer
										lowercase :							Tuple    		=n_head
										if d_model % n_head != 0:
																raise ValueError(F'''\'d_model % n_head\' ({d_model % n_head}) should be equal to 0'''   )
										if "d_head" in kwargs:
																if kwargs["d_head"] != d_model // n_head:
																						raise ValueError(
																						    F'''`d_head` ({kwargs["d_head"]}) should be equal to `d_model // n_head` ({d_model // n_head})'''   )
										lowercase :							Tuple    		=d_model // n_head
										lowercase :							Dict    		=ff_activation
										lowercase :							Tuple    		=d_inner
										lowercase :							str    		=untie_r
										lowercase :							Optional[Any]    		=attn_type

										lowercase :							Optional[int]    		=initializer_range
										lowercase :							List[Any]    		=layer_norm_eps

										lowercase :							Dict    		=dropout
										lowercase :							Optional[int]    		=mem_len
										lowercase :							Any    		=reuse_len
										lowercase :							Union[str, Any]    		=bi_data
										lowercase :							Optional[int]    		=clamp_len
										lowercase :							Tuple    		=same_length

										lowercase :							Optional[int]    		=summary_type
										lowercase :							str    		=summary_use_proj
										lowercase :							Optional[int]    		=summary_activation
										lowercase :							Tuple    		=summary_last_dropout
										lowercase :							Union[str, Any]    		=start_n_top
										lowercase :							Tuple    		=end_n_top

										lowercase :							Union[str, Any]    		=bos_token_id
										lowercase :							Union[str, Any]    		=pad_token_id
										lowercase :							Tuple    		=eos_token_id

										if "use_cache" in kwargs:
																warnings.warn(
																    '''The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`'''
																    ''' instead.'''		,					UpperCAmelCase__		,					)
																lowercase :							Optional[Any]    		=kwargs['''use_cache''']

										lowercase :							int    		=use_mems_eval
										lowercase :							List[str]    		=use_mems_train
										super().__init__(pad_token_id=UpperCAmelCase__		,					bos_token_id=UpperCAmelCase__		,					eos_token_id=UpperCAmelCase__		,					**UpperCAmelCase__   )







				@property
				def  lowerCamelCase_	(       self     :		Union[str, Any]   ):
										'''simple docstring'''
										logger.info(F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''   )
										return -1







				@max_position_embeddings.setter
				def  lowerCamelCase_	(       self     :		int		,					UpperCAmelCase__     :		str   ):
										'''simple docstring'''
										# Message copied from Transformer-XL documentation
										raise NotImplementedError(
										    F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''   )







'''simple docstring'''




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


lowercase     :							List[str]       						=     logging.get_logger(__name__)

lowercase     :							Optional[int]       						=     {
    'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json',
}





class 					A							(				__snake_case		):
     __magic_name__          =						'''switch_transformers'''
     __magic_name__          =						['''past_key_values''']
     __magic_name__          =						{'''hidden_size''': '''d_model''', '''num_attention_heads''': '''num_heads''', '''num_hidden_layers''': '''num_layers'''}





     def __init__(				self		,     SCREAMING_SNAKE_CASE=32128		,     SCREAMING_SNAKE_CASE=768		,     SCREAMING_SNAKE_CASE=64		,     SCREAMING_SNAKE_CASE=2048		,     SCREAMING_SNAKE_CASE=64		,     SCREAMING_SNAKE_CASE=12		,     SCREAMING_SNAKE_CASE=3		,     SCREAMING_SNAKE_CASE=12		,     SCREAMING_SNAKE_CASE=3		,     SCREAMING_SNAKE_CASE=12		,     SCREAMING_SNAKE_CASE=8		,     SCREAMING_SNAKE_CASE=False		,     SCREAMING_SNAKE_CASE=0.01		,     SCREAMING_SNAKE_CASE="float32"		,     SCREAMING_SNAKE_CASE=False		,     SCREAMING_SNAKE_CASE=32		,     SCREAMING_SNAKE_CASE=128		,     SCREAMING_SNAKE_CASE=0.1		,     SCREAMING_SNAKE_CASE=1e-6		,     SCREAMING_SNAKE_CASE=0.001		,     SCREAMING_SNAKE_CASE=0.001		,     SCREAMING_SNAKE_CASE=1.0		,     SCREAMING_SNAKE_CASE="relu"		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=False		,     SCREAMING_SNAKE_CASE=True		,     SCREAMING_SNAKE_CASE=0		,     SCREAMING_SNAKE_CASE=1		,     **SCREAMING_SNAKE_CASE		,     )					->							List[Any]:






         """simple docstring"""






         A			:  Union[str, Any]   =		vocab_size
         A			:  Any   =		d_model
         A			:  Dict   =		d_kv
         A			:  Optional[Any]   =		d_ff

         A			:  List[Any]   =		num_sparse_encoder_layers

         A			:  List[Any]   =		num_layers
         A			:  Optional[int]   =		(
             num_decoder_layers if num_decoder_layers is not None else self.num_layers
         )  # default = symmetry
         A			:  List[str]   =		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:
             A			:  int   =		self.num_layers // self.num_sparse_encoder_layers
         else:
             A			:  int   =		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:
             A			:  str   =		self.num_decoder_layers // self.num_sparse_decoder_layers
         else:
             A			:  Dict   =		self.num_decoder_layers  # HACK: this will create 0 sparse layers

         A			:  List[Any]   =		num_heads
         A			:  str   =		num_experts
         A			:  Dict   =		expert_capacity
         A			:  Optional[int]   =		router_bias
         A			:  Any   =		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}'      )
         A			:  Dict   =		router_dtype

         A			:  int   =		router_ignore_padding_tokens
         A			:  List[Any]   =		relative_attention_num_buckets
         A			:  Dict   =		relative_attention_max_distance

         A			:  Optional[int]   =		dropout_rate
         A			:  Dict   =		layer_norm_epsilon
         A			:  Optional[int]   =		initializer_factor
         A			:  Union[str, Any]   =		feed_forward_proj
         A			:  Any   =		use_cache
         A			:  Tuple   =		add_router_probs

         A			:  List[str]   =		router_z_loss_coef
         A			:  str   =		router_aux_loss_coef

         A			:  Union[str, Any]   =		self.feed_forward_proj.split('''-'''      )
         A			:  Optional[Any]   =		act_info[-1]
         A			:  Union[str, Any]   =		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":
             A			:  str   =		'''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		,     )




