




from typing import List

from .keymap import KEYMAP, get_character




def 		lowerCAmelCase_ (						lowerCamelCase ):

				def decorator(lowerCamelCase ):
								__magic_name__						:						str										=getattr(lowerCamelCase						,  """handle_key"""						,  [] )
								handle += [key]
								setattr(lowerCamelCase						,  """handle_key"""						,  lowerCamelCase )
								return func

				return decorator




def 		lowerCAmelCase_ (						*lowerCamelCase ):

				def decorator(lowerCamelCase ):
								__magic_name__						:						Dict										=getattr(lowerCamelCase						,  """handle_key"""						,  [] )
								handle += keys
								setattr(lowerCamelCase						,  """handle_key"""						,  lowerCamelCase )
								return func

				return decorator




class 		__A   (      UpperCamelCase__      ):

						def __new__(		cls :Dict     ,			__snake_case :Optional[Any]     ,			__snake_case :Union[str, Any]     ,			__snake_case :List[str]			):
										'''simple docstring'''

										__magic_name__						:						int										=super().__new__(cls     ,			__snake_case     ,			__snake_case     ,			__snake_case			)
										if not hasattr(__snake_case     ,			"""key_handler"""			):
														setattr(__snake_case     ,			"""key_handler"""     ,			{}			)
										setattr(__snake_case     ,			"""handle_input"""     ,			KeyHandler.handle_input			)

										for value in attrs.values():
														__magic_name__						:						int										=getattr(__snake_case     ,			"""handle_key"""     ,			[]			)
														for key in handled_keys:
																		__magic_name__						:						List[str]										=value
										return new_cls


						@staticmethod
						def      A__    (		cls :Optional[int]			):
										'''simple docstring'''

										__magic_name__						:						Union[str, Any]										=get_character()
										if char != KEYMAP["undefined"]:
														__magic_name__						:						Optional[int]										=ord(__snake_case			)
										__magic_name__						:						int										=cls.key_handler.get(__snake_case			)
										if handler:
														__magic_name__						:						Dict										=char
														return handler(cls			)
										else:
														return None




def 		lowerCAmelCase_ (						cls ):
				return KeyHandler(cls.__name__						,  cls.__bases__						,  cls.__dict__.copy() )





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


a  :      Any            =    logging.get_logger(__name__)

a  :      List[str]            =    {
    """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""",
}

class 					_lowercase    (     UpperCAmelCase__			):






    '''simple docstring'''
    SCREAMING_SNAKE_CASE:				Optional[Any]          =    'transfo-xl'
    SCREAMING_SNAKE_CASE:				List[Any]          =    ['mems']
    SCREAMING_SNAKE_CASE:				List[Any]          =    {
        'n_token': 'vocab_size',
        'hidden_size': 'd_model',
        'num_attention_heads': 'n_head',
        'num_hidden_layers': 'n_layer',
    }




    def __init__(    self       ,						lowerCamelCase__=267_735       ,						lowerCamelCase__=[20_000, 40_000, 200_000]       ,						lowerCamelCase__=1_024       ,						lowerCamelCase__=1_024       ,						lowerCamelCase__=16       ,						lowerCamelCase__=64       ,						lowerCamelCase__=4_096       ,						lowerCamelCase__=4       ,						lowerCamelCase__=False       ,						lowerCamelCase__=18       ,						lowerCamelCase__=1_600       ,						lowerCamelCase__=1_000       ,						lowerCamelCase__=True       ,						lowerCamelCase__=True       ,						lowerCamelCase__=0       ,						lowerCamelCase__=-1       ,						lowerCamelCase__=True       ,						lowerCamelCase__=0.1       ,						lowerCamelCase__=0.0       ,						lowerCamelCase__=True       ,						lowerCamelCase__="normal"       ,						lowerCamelCase__=0.0_1       ,						lowerCamelCase__=0.0_1       ,						lowerCamelCase__=0.0_2       ,						lowerCamelCase__=1E-5       ,						lowerCamelCase__=0       ,						**lowerCamelCase__       ,						):
       lowerCAmelCase_:							Dict       =	vocab_size
       lowerCAmelCase_:							Any       =	[]
       self.cutoffs.extend(lowerCamelCase__ )
       if proj_share_all_but_first:
          lowerCAmelCase_:							int       =	[False] + [True] * len(self.cutoffs )
       else:
          lowerCAmelCase_:							Any       =	[False] + [False] * len(self.cutoffs )
       lowerCAmelCase_:							Dict       =	d_model
       lowerCAmelCase_:							Union[str, Any]       =	d_embed
       lowerCAmelCase_:							Dict       =	d_head
       lowerCAmelCase_:							Dict       =	d_inner
       lowerCAmelCase_:							List[str]       =	div_val
       lowerCAmelCase_:							List[str]       =	pre_lnorm
       lowerCAmelCase_:							List[str]       =	n_layer
       lowerCAmelCase_:							List[str]       =	n_head
       lowerCAmelCase_:							str       =	mem_len
       lowerCAmelCase_:							Any       =	same_length
       lowerCAmelCase_:							Optional[Any]       =	attn_type
       lowerCAmelCase_:							int       =	clamp_len
       lowerCAmelCase_:							Optional[int]       =	sample_softmax
       lowerCAmelCase_:							Optional[Any]       =	adaptive
       lowerCAmelCase_:							Optional[int]       =	dropout
       lowerCAmelCase_:							Union[str, Any]       =	dropatt
       lowerCAmelCase_:							Tuple       =	untie_r
       lowerCAmelCase_:							Union[str, Any]       =	init
       lowerCAmelCase_:							Optional[Any]       =	init_range
       lowerCAmelCase_:							Optional[Any]       =	proj_init_std
       lowerCAmelCase_:							Tuple       =	init_std
       lowerCAmelCase_:							Tuple       =	layer_norm_epsilon
       super().__init__(eos_token_id=lowerCamelCase__       ,						**lowerCamelCase__ )




    @property
    def      _a    (    self ):
       # Message copied from Transformer-XL documentation
       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      _a    (    self       ,						lowerCamelCase__ ):
       # 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.''' )