


'''simple docstring'''


from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


_UpperCamelCase          =     logging.get_logger(__name__)







class        __magic_name__  (					lowerCAmelCase   ):

     """simple docstring"""






     lowerCamelCase__						=							['input_ids', 'attention_mask']


     def __init__(      self ,    lowerCamelCase="[PAD]" ,    lowerCamelCase="[BOS]" ,    lowerCamelCase="[EOS]" ,    lowerCamelCase="[MASK]" ,    lowerCamelCase="[CLS]" ,    lowerCamelCase="[SEP]" ,    lowerCamelCase=2048 ,    **lowerCamelCase ,    ):


          '''simple docstring'''





          __A  :					Optional[Any]						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else pad_token
          __A  :					Optional[int]						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else bos_token
          __A  :					List[str]						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else eos_token
          __A  :					List[str]						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else mask_token
          __A  :					int						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else cls_token
          __A  :					Dict						     =       AddedToken(lowerCamelCase ,    lstrip=lowerCamelCase ,    rstrip=lowerCamelCase		) if isinstance(lowerCamelCase ,    lowerCamelCase		) else sep_token

          super().__init__(
              pad_token=lowerCamelCase ,    bos_token=lowerCamelCase ,    eos_token=lowerCamelCase ,    mask_token=lowerCamelCase ,    cls_token=lowerCamelCase ,    sep_token=lowerCamelCase ,    model_max_length=lowerCamelCase ,    **lowerCamelCase ,    )

          __A  :					str						     =       2**8  # utf is 8 bits

          # define special tokens dict
          __A  :					Dict[str, int]						     =       {
              self.pad_token: 0,
              self.bos_token: 1,
              self.eos_token: 2,
              self.mask_token: 3,
              self.cls_token: 4,
              self.sep_token: 5,
          }
          __A  :					Optional[Any]						     =       len(self.special_tokens_encoder		)
          __A  :					Dict[int, str]						     =       {v: k for k, v in self.special_tokens_encoder.items()}


     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          __A  :					Dict						     =       self.special_tokens_encoder.copy()
          vocab.update(self.added_tokens_encoder		)
          for i in range(self._utf_vocab_size		):
               __A  :					Optional[int]						     =       chr(lowerCamelCase		)
               __A  :					Dict						     =       i + len(self.special_tokens_encoder		)
          return vocab


     @property
     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          return self._utf_vocab_size + self._num_special_tokens


     def lowerCAmelCase__     (      self ,    lowerCamelCase ,    lowerCamelCase = None ,    lowerCamelCase = False		):


          '''simple docstring'''





          if already_has_special_tokens:
               return super().get_special_tokens_mask(
                   token_ids_a=lowerCamelCase ,    token_ids_a=lowerCamelCase ,    already_has_special_tokens=lowerCamelCase		)

          # normal case: some special tokens
          if token_ids_a is None:
               return [1] + [0] * len(lowerCamelCase		) + [1]
          return [1] + ([0] * len(lowerCamelCase		)) + [1] + ([0] * len(lowerCamelCase		)) + [1]


     def lowerCAmelCase__     (      self ,    lowerCamelCase ,    lowerCamelCase = None		):


          '''simple docstring'''





          if token_ids_a is None:
               return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
          else:
               return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]


     def lowerCAmelCase__     (      self ,    lowerCamelCase		):


          '''simple docstring'''





          __A  :					Optional[int]						     =       [chr(lowerCamelCase		) for i in text.encode("utf-8"		)]
          return tokens


     def lowerCAmelCase__     (      self ,    lowerCamelCase		):


          '''simple docstring'''





          if token in self.special_tokens_encoder:
               __A  :					str						     =       self.special_tokens_encoder[token]
          elif token in self.added_tokens_encoder:
               __A  :					Optional[Any]						     =       self.added_tokens_encoder[token]
          elif len(lowerCamelCase		) != 1:
               __A  :					List[str]						     =       self.unk_token_id
          else:
               __A  :					List[str]						     =       ord(lowerCamelCase		) + self._num_special_tokens
          return token_id


     def lowerCAmelCase__     (      self ,    lowerCamelCase		):


          '''simple docstring'''





          if index in self.special_tokens_decoder:
               __A  :					List[Any]						     =       self.special_tokens_decoder[index]
          elif index in self.added_tokens_decoder:
               __A  :					str						     =       self.added_tokens_decoder[index]
          else:
               __A  :					int						     =       chr(index - self._num_special_tokens		)
          return token


     def lowerCAmelCase__     (      self ,    lowerCamelCase		):


          '''simple docstring'''





          __A  :					Optional[Any]						     =       b""
          for token in tokens:
               if token in self.special_tokens_decoder:
                    __A  :					Dict						     =       self.special_tokens_decoder[token].encode("utf-8"		)
               elif token in self.added_tokens_decoder:
                    __A  :					List[str]						     =       self.special_tokens_decoder[token].encode("utf-8"		)
               elif token in self.special_tokens_encoder:
                    __A  :					Optional[Any]						     =       token.encode("utf-8"		)
               elif token in self.added_tokens_encoder:
                    __A  :					Optional[int]						     =       token.encode("utf-8"		)
               else:
                    __A  :					Optional[Any]						     =       bytes([ord(lowerCamelCase		)]		)
               bstring += tok_string
          __A  :					Optional[int]						     =       bstring.decode("utf-8" ,    errors="replace"		)
          return string


     def lowerCAmelCase__     (      self ,    lowerCamelCase ,    lowerCamelCase = None		):


          '''simple docstring'''





          return ()





'''simple docstring'''


from sklearn.metrics import accuracy_score

import datasets


_UpperCamelCase          =     """
Accuracy is the proportion of correct predictions among the total number of cases processed. It can be computed with:
Accuracy = (TP + TN) / (TP + TN + FP + FN)
 Where:
TP: True positive
TN: True negative
FP: False positive
FN: False negative
"""


_UpperCamelCase          =     """
Args:
    predictions (`list` of `int`): Predicted labels.
    references (`list` of `int`): Ground truth labels.
    normalize (`boolean`): If set to False, returns the number of correctly classified samples. Otherwise, returns the fraction of correctly classified samples. Defaults to True.
    sample_weight (`list` of `float`): Sample weights Defaults to None.

Returns:
    accuracy (`float` or `int`): Accuracy score. Minimum possible value is 0. Maximum possible value is 1.0, or the number of examples input, if `normalize` is set to `True`.. A higher score means higher accuracy.

Examples:

    Example 1-A simple example
        >>> accuracy_metric = datasets.load_metric(\"accuracy\")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0])
        >>> print(results)
        {'accuracy': 0.5}

    Example 2-The same as Example 1, except with `normalize` set to `False`.
        >>> accuracy_metric = datasets.load_metric(\"accuracy\")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0], normalize=False)
        >>> print(results)
        {'accuracy': 3.0}

    Example 3-The same as Example 1, except with `sample_weight` set.
        >>> accuracy_metric = datasets.load_metric(\"accuracy\")
        >>> results = accuracy_metric.compute(references=[0, 1, 2, 0, 1, 2], predictions=[0, 1, 1, 2, 1, 0], sample_weight=[0.5, 2, 0.7, 0.5, 9, 0.4])
        >>> print(results)
        {'accuracy': 0.8778625954198473}
"""


_UpperCamelCase          =     """
@article{scikit-learn,
  title={Scikit-learn: Machine Learning in {P}ython},
  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.
         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.
         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and
         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},
  journal={Journal of Machine Learning Research},
  volume={12},
  pages={2825--2830},
  year={2011}
}
"""







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

     """simple docstring"""






     def lowerCAmelCase__     (      self		):


          '''simple docstring'''





          return datasets.MetricInfo(
              description=_DESCRIPTION ,    citation=_CITATION ,    inputs_description=_KWARGS_DESCRIPTION ,    features=datasets.Features(
                  {
                      "predictions": datasets.Sequence(datasets.Value("int32"		)		),
                      "references": datasets.Sequence(datasets.Value("int32"		)		),
                  }
                  if self.config_name == "multilabel"
                  else {
                      "predictions": datasets.Value("int32"		),
                      "references": datasets.Value("int32"		),
                  }		) ,    reference_urls=["https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html"] ,    )


     def lowerCAmelCase__     (      self ,    lowerCamelCase ,    lowerCamelCase ,    lowerCamelCase=True ,    lowerCamelCase=None		):


          '''simple docstring'''





          return {
              "accuracy": float(
                  accuracy_score(lowerCamelCase ,    lowerCamelCase ,    normalize=lowerCamelCase ,    sample_weight=lowerCamelCase		)		)
          }

