



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 				lowerCAmelCase_		(  __A							):
       UpperCAmelCase__				:					List[str]        =  "xlnet"
       UpperCAmelCase__				:					Union[str, Any]        =  ["mems"]
       UpperCAmelCase__				:					Tuple        =  {
           "n_token": "vocab_size",  # Backward compatibility
           "hidden_size": "d_model",
           "num_attention_heads": "n_head",
           "num_hidden_layers": "n_layer",
       }
       def __init__(			self,			SCREAMING_SNAKE_CASE_=3_2000,			SCREAMING_SNAKE_CASE_=1024,			SCREAMING_SNAKE_CASE_=24,			SCREAMING_SNAKE_CASE_=16,			SCREAMING_SNAKE_CASE_=4096,			SCREAMING_SNAKE_CASE_="gelu",			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_="bi",			SCREAMING_SNAKE_CASE_=0.02,			SCREAMING_SNAKE_CASE_=1e-12,			SCREAMING_SNAKE_CASE_=0.1,			SCREAMING_SNAKE_CASE_=512,			SCREAMING_SNAKE_CASE_=None,			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_=False,			SCREAMING_SNAKE_CASE_=False,			SCREAMING_SNAKE_CASE_=-1,			SCREAMING_SNAKE_CASE_=False,			SCREAMING_SNAKE_CASE_="last",			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_="tanh",			SCREAMING_SNAKE_CASE_=0.1,			SCREAMING_SNAKE_CASE_=5,			SCREAMING_SNAKE_CASE_=5,			SCREAMING_SNAKE_CASE_=5,			SCREAMING_SNAKE_CASE_=1,			SCREAMING_SNAKE_CASE_=2,			**SCREAMING_SNAKE_CASE_,			)     ->		List[str]:
          UpperCamelCase    :  Union[str, Any]							=	vocab_size
          UpperCamelCase    :  List[str]							=	d_model
          UpperCamelCase    :  List[Any]							=	n_layer
          UpperCamelCase    :  Optional[int]							=	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})"""       )
          UpperCamelCase    :  Optional[Any]							=	d_model // n_head
          UpperCamelCase    :  List[str]							=	ff_activation
          UpperCamelCase    :  Union[str, Any]							=	d_inner
          UpperCamelCase    :  str							=	untie_r
          UpperCamelCase    :  List[Any]							=	attn_type

          UpperCamelCase    :  Optional[Any]							=	initializer_range
          UpperCamelCase    :  Optional[Any]							=	layer_norm_eps

          UpperCamelCase    :  Any							=	dropout
          UpperCamelCase    :  str							=	mem_len
          UpperCamelCase    :  List[str]							=	reuse_len
          UpperCamelCase    :  Dict							=	bi_data
          UpperCamelCase    :  Tuple							=	clamp_len
          UpperCamelCase    :  Optional[int]							=	same_length

          UpperCamelCase    :  Union[str, Any]							=	summary_type
          UpperCamelCase    :  Union[str, Any]							=	summary_use_proj
          UpperCamelCase    :  Union[str, Any]							=	summary_activation
          UpperCamelCase    :  str							=	summary_last_dropout
          UpperCamelCase    :  List[Any]							=	start_n_top
          UpperCamelCase    :  Union[str, Any]							=	end_n_top

          UpperCamelCase    :  Union[str, Any]							=	bos_token_id
          UpperCamelCase    :  List[str]							=	pad_token_id
          UpperCamelCase    :  Optional[int]							=	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,			)
             UpperCamelCase    :  List[Any]							=	kwargs['use_cache']

          UpperCamelCase    :  Any							=	use_mems_eval
          UpperCamelCase    :  Union[str, Any]							=	use_mems_train
          super().__init__(pad_token_id=_UpperCamelCase,			bos_token_id=_UpperCamelCase,			eos_token_id=_UpperCamelCase,			**_UpperCamelCase       )
       @property
       def 					snake_case_       (			self       )     ->		Union[str, Any]:
          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 					snake_case_       (			self,			SCREAMING_SNAKE_CASE_       )     ->		int:
          # 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."""       )






from collections import deque

from .hash_table import HashTable





class 	snake_case_   (		__A					):







			'''simple docstring'''

			def __init__(     self :				int							,   *_UpperCamelCase :				int							,   **_UpperCamelCase :				Tuple							)      ->Tuple:
									super().__init__(*_UpperCamelCase							,   **_UpperCamelCase							)







			def 				snake_case__(     self :				Dict							,   _UpperCamelCase :				List[str]							,   _UpperCamelCase :				Dict							)      ->Tuple:
									snake_case_   =	deque([]							) if self.values[key] is None else self.values[key]
									self.values[key].appendleft(_UpperCamelCase							)
									snake_case_   =	self.values[key]







			def 				snake_case__(     self :				List[Any]							)      ->str:
									return (
									    sum(self.charge_factor - len(_UpperCamelCase							) for slot in self.values							)
									    / self.size_table
									    * self.charge_factor
									)







			def 				snake_case__(     self :				Dict							,   _UpperCamelCase :				Union[str, Any]							,   _UpperCamelCase :				Optional[int]=None							)      ->str:
									if not (
									    len(self.values[key]							) == self.charge_factor and self.values.count(_UpperCamelCase							) == 0
									):
															return key
									return super()._collision_resolution(_UpperCamelCase							,   _UpperCamelCase							)