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   snake_case_       (		__A       ):
   __A	:		int         =				"xlnet"
   __A	:		List[Any]         =				["mems"]
   __A	:		List[str]         =				{
       "n_token": "vocab_size",  # Backward compatibility
       "hidden_size": "d_model",
       "num_attention_heads": "n_head",
       "num_hidden_layers": "n_layer",
   }






   def __init__(      self				:     Dict	,						lowercase_				:     List[Any]=3_20_00	,						lowercase_				:     Any=10_24	,						lowercase_				:     Dict=24	,						lowercase_				:     Any=16	,						lowercase_				:     List[Any]=40_96	,						lowercase_				:     Union[str, Any]="gelu"	,						lowercase_				:     Dict=True	,						lowercase_				:     Dict="bi"	,						lowercase_				:     Optional[int]=0.02	,						lowercase_				:     Optional[Any]=1E-12	,						lowercase_				:     Union[str, Any]=0.1	,						lowercase_				:     Tuple=5_12	,						lowercase_				:     Union[str, Any]=None	,						lowercase_				:     str=True	,						lowercase_				:     List[Any]=False	,						lowercase_				:     Union[str, Any]=False	,						lowercase_				:     List[str]=-1	,						lowercase_				:     Optional[int]=False	,						lowercase_				:     str="last"	,						lowercase_				:     List[Any]=True	,						lowercase_				:     Any="tanh"	,						lowercase_				:     Union[str, Any]=0.1	,						lowercase_				:     int=5	,						lowercase_				:     str=5	,						lowercase_				:     str=5	,						lowercase_				:     Optional[int]=1	,						lowercase_				:     Dict=2	,						**lowercase_				:     Union[str, Any]	,						)					->						int:
       lowercase__ :   Optional[int]    					=				vocab_size
       lowercase__ :   List[str]    					=				d_model
       lowercase__ :   Union[str, Any]    					=				n_layer
       lowercase__ :   Any    					=				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__ :   List[Any]    					=				d_model // n_head
       lowercase__ :   List[str]    					=				ff_activation
       lowercase__ :   Optional[Any]    					=				d_inner
       lowercase__ :   int    					=				untie_r
       lowercase__ :   int    					=				attn_type

       lowercase__ :   Dict    					=				initializer_range
       lowercase__ :   List[str]    					=				layer_norm_eps

       lowercase__ :   List[Any]    					=				dropout
       lowercase__ :   Optional[Any]    					=				mem_len
       lowercase__ :   Any    					=				reuse_len
       lowercase__ :   List[str]    					=				bi_data
       lowercase__ :   str    					=				clamp_len
       lowercase__ :   Tuple    					=				same_length

       lowercase__ :   List[Any]    					=				summary_type
       lowercase__ :   str    					=				summary_use_proj
       lowercase__ :   List[str]    					=				summary_activation
       lowercase__ :   List[str]    					=				summary_last_dropout
       lowercase__ :   str    					=				start_n_top
       lowercase__ :   List[str]    					=				end_n_top

       lowercase__ :   List[Any]    					=				bos_token_id
       lowercase__ :   Tuple    					=				pad_token_id
       lowercase__ :   Any    					=				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."	,						lowercase_	,						)
           lowercase__ :   Tuple    					=				kwargs["use_cache"]

       lowercase__ :   str    					=				use_mems_eval
       lowercase__ :   List[str]    					=				use_mems_train
       super().__init__(pad_token_id=lowercase_	,						bos_token_id=lowercase_	,						eos_token_id=lowercase_	,						**lowercase_  )






   @property
   def       __UpperCamelCase     (      self				:     List[Any]  )					->						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       __UpperCamelCase     (      self				:     Dict	,						lowercase_				:     List[Any]  )					->						Any:
       # 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 unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset


class 					a_     (				snake_case_       ):

    '''simple docstring'''


    def 			snake_case_(		self       )		->   Tuple:
        return [
            {"col_1": 3, "col_2": "a"},
            {"col_1": 2, "col_2": "b"},
            {"col_1": 1, "col_2": "c"},
            {"col_1": 0, "col_2": "d"},
        ]


    def 			snake_case_(		self       )		->   Optional[int]:
        _SCREAMING_SNAKE_CASE									=			{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
        return Dataset.from_dict(A       )


    def 			snake_case_(		self       )		->   str:
        _SCREAMING_SNAKE_CASE									=			self._create_example_records()
        _SCREAMING_SNAKE_CASE									=			Dataset.from_list(A       )
        self.assertListEqual(dset.column_names ,		["""col_1""", """col_2"""]       )
        for i, r in enumerate(A       ):
            self.assertDictEqual(A ,		example_records[i]       )


    def 			snake_case_(		self       )		->   str:
        _SCREAMING_SNAKE_CASE									=			self._create_example_records()
        _SCREAMING_SNAKE_CASE									=			Dataset.from_list(A       )
        _SCREAMING_SNAKE_CASE									=			Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]}       )
        self.assertEqual(dset.info ,		dset_from_dict.info       )


    def 			snake_case_(		self       )		->   Union[str, Any]:  # checks what happens with missing columns
        _SCREAMING_SNAKE_CASE									=			[{"""col_1""": 1}, {"""col_2""": """x"""}]
        _SCREAMING_SNAKE_CASE									=			Dataset.from_list(A       )
        self.assertDictEqual(dset[0] ,		{"""col_1""": 1}       )
        self.assertDictEqual(dset[1] ,		{"""col_1""": None}       )  # NB: first record is used for columns


    def 			snake_case_(		self       )		->   Optional[Any]:  # checks if the type can be inferred from the second record
        _SCREAMING_SNAKE_CASE									=			[{"""col_1""": []}, {"""col_1""": [1, 2]}]
        _SCREAMING_SNAKE_CASE									=			Dataset.from_list(A       )
        self.assertEqual(dset.info.features["""col_1"""] ,		Sequence(Value("""int64"""       )       )       )





    def 			snake_case_(		self       )		->   str:
        _SCREAMING_SNAKE_CASE									=			Dataset.from_list([]       )
        self.assertEqual(len(A       ) ,		0       )
        self.assertListEqual(dset.column_names ,		[]       )



