



"""simple docstring"""





import warnings

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


lowercase					=       logging.get_logger(__name__)

lowercase					=       {
    """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       lowercase__      (   _UpperCAmelCase     ):
							'''simple docstring'''







							_UpperCAmelCase   					=       '''xlnet'''
							_UpperCAmelCase   					=       ['''mems''']
							_UpperCAmelCase   					=       {
							    '''n_token''': '''vocab_size''',  # Backward compatibility
							    '''hidden_size''': '''d_model''',
							    '''num_attention_heads''': '''n_head''',
							    '''num_hidden_layers''': '''n_layer''',
							}






							def __init__(	self						,							snake_case=32000						,							snake_case=1024						,							snake_case=24						,							snake_case=16						,							snake_case=4096						,							snake_case="gelu"						,							snake_case=True						,							snake_case="bi"						,							snake_case=0.02						,							snake_case=1E-12						,							snake_case=0.1						,							snake_case=512						,							snake_case=None						,							snake_case=True						,							snake_case=False						,							snake_case=False						,							snake_case=-1						,							snake_case=False						,							snake_case="last"						,							snake_case=True						,							snake_case="tanh"						,							snake_case=0.1						,							snake_case=5						,							snake_case=5						,							snake_case=5						,							snake_case=1						,							snake_case=2						,							**snake_case						,							)      ->				Any:
									_UpperCAmelCase							=		vocab_size
									_UpperCAmelCase							=		d_model
									_UpperCAmelCase							=		n_layer
									_UpperCAmelCase							=		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							=		d_model // n_head
									_UpperCAmelCase							=		ff_activation
									_UpperCAmelCase							=		d_inner
									_UpperCAmelCase							=		untie_r
									_UpperCAmelCase							=		attn_type

									_UpperCAmelCase							=		initializer_range
									_UpperCAmelCase							=		layer_norm_eps

									_UpperCAmelCase							=		dropout
									_UpperCAmelCase							=		mem_len
									_UpperCAmelCase							=		reuse_len
									_UpperCAmelCase							=		bi_data
									_UpperCAmelCase							=		clamp_len
									_UpperCAmelCase							=		same_length

									_UpperCAmelCase							=		summary_type
									_UpperCAmelCase							=		summary_use_proj
									_UpperCAmelCase							=		summary_activation
									_UpperCAmelCase							=		summary_last_dropout
									_UpperCAmelCase							=		start_n_top
									_UpperCAmelCase							=		end_n_top

									_UpperCAmelCase							=		bos_token_id
									_UpperCAmelCase							=		pad_token_id
									_UpperCAmelCase							=		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.'						,							lowerCAmelCase__						,							)
											_UpperCAmelCase							=		kwargs['use_cache']

									_UpperCAmelCase							=		use_mems_eval
									_UpperCAmelCase							=		use_mems_train
									super().__init__(pad_token_id=lowerCAmelCase__						,							bos_token_id=lowerCAmelCase__						,							eos_token_id=lowerCAmelCase__						,							**lowerCAmelCase__    )






							@property
							def 							lowerCamelCase_ (	self    )      ->				List[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 							lowerCamelCase_ (	self						,							snake_case    )      ->				Tuple:
									raise NotImplementedError(
									    f'The model {self.model_type} is one of the few models that has no sequence length limit.'    )



import datasets


__a    :	Optional[Any]         =    """\
@InProceedings{conneau2018xnli,
  author = \"Conneau, Alexis
                 and Rinott, Ruty
                 and Lample, Guillaume
                 and Williams, Adina
                 and Bowman, Samuel R.
                 and Schwenk, Holger
                 and Stoyanov, Veselin\",
  title = \"XNLI: Evaluating Cross-lingual Sentence Representations\",
  booktitle = \"Proceedings of the 2018 Conference on Empirical Methods
               in Natural Language Processing\",
  year = \"2018\",
  publisher = \"Association for Computational Linguistics\",
  location = \"Brussels, Belgium\",
}
"""

__a    :	Optional[Any]         =    """\
XNLI is a subset of a few thousand examples from MNLI which has been translated
into a 14 different languages (some low-ish resource). As with MNLI, the goal is
to predict textual entailment (does sentence A imply/contradict/neither sentence
B) and is a classification task (given two sentences, predict one of three
labels).
"""

__a    :	str         =    """
Computes XNLI score which is just simple accuracy.
Args:
    predictions: Predicted labels.
    references: Ground truth labels.
Returns:
    'accuracy': accuracy
Examples:

    >>> predictions = [0, 1]
    >>> references = [0, 1]
    >>> xnli_metric = datasets.load_metric(\"xnli\")
    >>> results = xnli_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0}
"""





def 							UpperCAmelCase		(       lowercase				,     lowercase				):







				"""simple docstring"""



				return (preds == labels).mean()




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION		,_KWARGS_DESCRIPTION					)
class   _UpperCamelCase (		datasets.Metric					):


			"""simple docstring"""






			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   str:

							'''simple docstring'''


							return datasets.MetricInfo(
							    description=_DESCRIPTION ,  citation=_CITATION ,  inputs_description=_KWARGS_DESCRIPTION ,  features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							            '''references''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							        }		) ,  codebase_urls=[] ,  reference_urls=[] ,  format='''numpy''' ,  )





			def 			_SCREAMING_SNAKE_CASE     (  self ,  lowerCAmelCase__ ,  lowerCAmelCase__		)	->   Dict:

							'''simple docstring'''


							return {"accuracy": simple_accuracy(lowerCAmelCase__ ,  lowerCAmelCase__		)}