




'''simple docstring'''






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_distilbert import DistilBertTokenizer


a_					:    int          =    logging.get_logger(__name__)

a_					:    List[Any]          =    {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

a_					:    str          =    {
    "vocab_file": {
        "distilbert-base-uncased": "https://huggingface.co/distilbert-base-uncased/resolve/main/vocab.txt",
        "distilbert-base-uncased-distilled-squad": (
            "https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/vocab.txt"
        ),
        "distilbert-base-cased": "https://huggingface.co/distilbert-base-cased/resolve/main/vocab.txt",
        "distilbert-base-cased-distilled-squad": (
            "https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/vocab.txt"
        ),
        "distilbert-base-german-cased": "https://huggingface.co/distilbert-base-german-cased/resolve/main/vocab.txt",
        "distilbert-base-multilingual-cased": (
            "https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "distilbert-base-uncased": "https://huggingface.co/distilbert-base-uncased/resolve/main/tokenizer.json",
        "distilbert-base-uncased-distilled-squad": (
            "https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/tokenizer.json"
        ),
        "distilbert-base-cased": "https://huggingface.co/distilbert-base-cased/resolve/main/tokenizer.json",
        "distilbert-base-cased-distilled-squad": (
            "https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/tokenizer.json"
        ),
        "distilbert-base-german-cased": (
            "https://huggingface.co/distilbert-base-german-cased/resolve/main/tokenizer.json"
        ),
        "distilbert-base-multilingual-cased": (
            "https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/tokenizer.json"
        ),
    },
}

a_					:    List[Any]          =    {
    "distilbert-base-uncased": 5_1_2,
    "distilbert-base-uncased-distilled-squad": 5_1_2,
    "distilbert-base-cased": 5_1_2,
    "distilbert-base-cased-distilled-squad": 5_1_2,
    "distilbert-base-german-cased": 5_1_2,
    "distilbert-base-multilingual-cased": 5_1_2,
}


a_					:    Any          =    {
    "distilbert-base-uncased": {"do_lower_case": True},
    "distilbert-base-uncased-distilled-squad": {"do_lower_case": True},
    "distilbert-base-cased": {"do_lower_case": False},
    "distilbert-base-cased-distilled-squad": {"do_lower_case": False},
    "distilbert-base-german-cased": {"do_lower_case": False},
    "distilbert-base-multilingual-cased": {"do_lower_case": False},
}




class  a     (     _SCREAMING_SNAKE_CASE       ):
 _lowerCAmelCase 					=	VOCAB_FILES_NAMES
 _lowerCAmelCase 					=	PRETRAINED_VOCAB_FILES_MAP
 _lowerCAmelCase 					=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _lowerCAmelCase 					=	PRETRAINED_INIT_CONFIGURATION
 _lowerCAmelCase 					=	["""input_ids""", """attention_mask"""]
 _lowerCAmelCase 					=	DistilBertTokenizer
 def __init__( self      ,				__magic_name__=None      ,				__magic_name__=None      ,				__magic_name__=True      ,				__magic_name__="[UNK]"      ,				__magic_name__="[SEP]"      ,				__magic_name__="[PAD]"      ,				__magic_name__="[CLS]"      ,				__magic_name__="[MASK]"      ,				__magic_name__=True      ,				__magic_name__=None      ,				**__magic_name__      ,				)					->							str:
      super().__init__(
          __magic_name__      ,				tokenizer_file=__magic_name__      ,				do_lower_case=__magic_name__      ,				unk_token=__magic_name__      ,				sep_token=__magic_name__      ,				pad_token=__magic_name__      ,				cls_token=__magic_name__      ,				mask_token=__magic_name__      ,				tokenize_chinese_chars=__magic_name__      ,				strip_accents=__magic_name__      ,				**__magic_name__      ,				)

      _a			      =							json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
      if (
          normalizer_state.get('lowercase'      ,				__magic_name__						) != do_lower_case
          or normalizer_state.get('strip_accents'      ,				__magic_name__						) != strip_accents
          or normalizer_state.get('handle_chinese_chars'      ,				__magic_name__						) != tokenize_chinese_chars
      ):
           _a			      =							getattr(__magic_name__      ,				normalizer_state.pop('type'						)						)
           _a			      =							do_lower_case
           _a			      =							strip_accents
           _a			      =							tokenize_chinese_chars
           _a			      =							normalizer_class(**__magic_name__						)

      _a			      =							do_lower_case
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__=None						)					->							Union[str, Any]:
      _a			      =							[self.cls_token_id] + token_ids_a + [self.sep_token_id]

      if token_ids_a:
           output += token_ids_a + [self.sep_token_id]

      return output
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__ = None						)					->							List[int]:
      _a			      =							[self.sep_token_id]
      _a			      =							[self.cls_token_id]
      if token_ids_a is None:
           return len(cls + token_ids_a + sep						) * [0]
      return len(cls + token_ids_a + sep						) * [0] + len(token_ids_a + sep						) * [1]




 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__ = None						)					->							Tuple[str]:
      _a			      =							self._tokenizer.model.save(__magic_name__      ,				name=__magic_name__						)
      return tuple(__magic_name__						)





'''simple docstring'''






import datasets


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

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

a_					:    Optional[Any]          =    "\nComputes XNLI score which is just simple accuracy.\nArgs:\n    predictions: Predicted labels.\n    references: Ground truth labels.\nReturns:\n    'accuracy': accuracy\nExamples:\n\n    >>> predictions = [0, 1]\n    >>> references = [0, 1]\n    >>> xnli_metric = datasets.load_metric(\"xnli\")\n    >>> results = xnli_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'accuracy': 1.0}\n"






def 	_A				(lowerCAmelCase__  :List[Any]				,						lowerCAmelCase__  :Tuple		)   ->  Dict:




     '''simple docstring'''



     return (preds == labels).mean()






@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION  ,				_KWARGS_DESCRIPTION       )
class  a     (     datasets.Metric       ):
 def 							__UpperCAmelCase		( self						)					->							Dict:
      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 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__						)					->							Dict:
      return {"accuracy": simple_accuracy(__magic_name__      ,				__magic_name__						)}

