
'''simple docstring'''






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


A			      =      logging.get_logger(__name__)

A			      =      {
    "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json",
}




class     __snake_case		(   UpperCAmelCase_):
					_lowerCAmelCase			     =	'transfo-xl'
					_lowerCAmelCase			     =	['mems']
					_lowerCAmelCase			     =	{
					    'n_token': 'vocab_size',
					    'hidden_size': 'd_model',
					    'num_attention_heads': 'n_head',
					    'num_hidden_layers': 'n_layer',
					}
					def __init__(     self,    A=26_7735,    A=[2_0000, 4_0000, 20_0000],    A=1024,    A=1024,    A=16,    A=64,    A=4096,    A=4,    A=False,    A=18,    A=1600,    A=1000,    A=True,    A=True,    A=0,    A=-1,    A=True,    A=0.1,    A=0.0,    A=True,    A="normal",    A=0.01,    A=0.01,    A=0.02,    A=1e-5,    A=0,    **A,    ):

									"""simple docstring"""


									lowerCamelCase					:			Union[str, Any]									= vocab_size
									lowerCamelCase					:			str									= []
									self.cutoffs.extend(_lowercase      )
									if proj_share_all_but_first:
													lowerCamelCase					:			List[Any]									= [False] + [True] * len(self.cutoffs      )
									else:
													lowerCamelCase					:			List[str]									= [False] + [False] * len(self.cutoffs      )
									lowerCamelCase					:			str									= d_model
									lowerCamelCase					:			int									= d_embed
									lowerCamelCase					:			Dict									= d_head
									lowerCamelCase					:			Optional[int]									= d_inner
									lowerCamelCase					:			int									= div_val
									lowerCamelCase					:			List[str]									= pre_lnorm
									lowerCamelCase					:			Any									= n_layer
									lowerCamelCase					:			Dict									= n_head
									lowerCamelCase					:			Tuple									= mem_len
									lowerCamelCase					:			Optional[int]									= same_length
									lowerCamelCase					:			List[str]									= attn_type
									lowerCamelCase					:			Optional[int]									= clamp_len
									lowerCamelCase					:			int									= sample_softmax
									lowerCamelCase					:			List[str]									= adaptive
									lowerCamelCase					:			List[str]									= dropout
									lowerCamelCase					:			Union[str, Any]									= dropatt
									lowerCamelCase					:			int									= untie_r
									lowerCamelCase					:			Optional[Any]									= init
									lowerCamelCase					:			Union[str, Any]									= init_range
									lowerCamelCase					:			Any									= proj_init_std
									lowerCamelCase					:			List[Any]									= init_std
									lowerCamelCase					:			Optional[Any]									= layer_norm_epsilon
									super().__init__(eos_token_id=_lowercase,    **_lowercase      )
					@property
					def     UpperCAmelCase_							(     self      ):

									"""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     UpperCAmelCase_							(     self,    A      ):

									"""simple docstring"""


									raise NotImplementedError(
									    F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''      )





'''simple docstring'''






import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


A			      =      {
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}





def    UpperCAmelCase							(  UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Optional[Any]       ,							UpperCAmelCase__							:							Union[str, Any]       ,							UpperCAmelCase__							:							List[Any]       ,							UpperCAmelCase__							:							Dict       ,							UpperCAmelCase__							:							Optional[int]):
				if got_ver is None or want_ver is None:
								raise ValueError(
								    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
								    F''' reinstalling {pkg}.''')
				if not ops[op](version.parse(UpperCAmelCase__)       ,							version.parse(UpperCAmelCase__)):
								raise ImportError(
								    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}''')





def    UpperCAmelCase							(  UpperCAmelCase__							:							str       ,							UpperCAmelCase__							:							Optional[str] = None):
				lowerCamelCase					:			List[Any]									= F'''\n{hint}''' if hint is not None else ''

				# non-versioned check
				if re.match(R'^[\w_\-\d]+$'       ,							UpperCAmelCase__):
								lowerCamelCase			, lowerCamelCase			, lowerCamelCase					:			Optional[Any]									= requirement, None, None
				else:
								lowerCamelCase					:			Optional[Any]									= re.findall(R'^([^!=<>\s]+)([\s!=<>]{1,2}.+)'       ,							UpperCAmelCase__)
								if not match:
												raise ValueError(
												    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'
												    F''' got {requirement}''')
								lowerCamelCase			, lowerCamelCase					:			Dict									= match[0]
								lowerCamelCase					:			Dict									= want_full.split(',')  # there could be multiple requirements
								lowerCamelCase					:			Union[str, Any]									= {}
								for w in want_range:
												lowerCamelCase					:			int									= re.findall(R'^([\s!=<>]{1,2})(.+)'       ,							UpperCAmelCase__)
												if not match:
																raise ValueError(
																    'requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'
																    F''' but got {requirement}''')
												lowerCamelCase			, lowerCamelCase					:			List[Any]									= match[0]
												lowerCamelCase					:			Optional[int]									= want_ver
												if op not in ops:
																raise ValueError(F'''{requirement}: need one of {list(ops.keys())}, but got {op}''')

    # special case
				if pkg == "python":
								lowerCamelCase					:			Optional[int]									= '.'.join([str(UpperCAmelCase__) for x in sys.version_info[:3]])
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)
								return

				# check if any version is installed
				try:
								lowerCamelCase					:			Any									= importlib.metadata.version(UpperCAmelCase__)
				except importlib.metadata.PackageNotFoundError:
								raise importlib.metadata.PackageNotFoundError(
								    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}''')

				# check that the right version is installed if version number or a range was provided
				if want_ver is not None:
								for op, want_ver in wanted.items():
												_compare_versions(UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__       ,							UpperCAmelCase__)





def    UpperCAmelCase							(  UpperCAmelCase__							:							str):
				lowerCamelCase					:			List[str]									= 'Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'
				return require_version(UpperCAmelCase__       ,							UpperCAmelCase__)
