






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_electra import ElectraTokenizer


lowercase						:      Dict									= {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

lowercase						:      int									= {
    'vocab_file': {
        'google/electra-small-generator': (
            'https://huggingface.co/google/electra-small-generator/resolve/main/vocab.txt'
        ),
        'google/electra-base-generator': 'https://huggingface.co/google/electra-base-generator/resolve/main/vocab.txt',
        'google/electra-large-generator': (
            'https://huggingface.co/google/electra-large-generator/resolve/main/vocab.txt'
        ),
        'google/electra-small-discriminator': (
            'https://huggingface.co/google/electra-small-discriminator/resolve/main/vocab.txt'
        ),
        'google/electra-base-discriminator': (
            'https://huggingface.co/google/electra-base-discriminator/resolve/main/vocab.txt'
        ),
        'google/electra-large-discriminator': (
            'https://huggingface.co/google/electra-large-discriminator/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'google/electra-small-generator': (
            'https://huggingface.co/google/electra-small-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-base-generator': (
            'https://huggingface.co/google/electra-base-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-large-generator': (
            'https://huggingface.co/google/electra-large-generator/resolve/main/tokenizer.json'
        ),
        'google/electra-small-discriminator': (
            'https://huggingface.co/google/electra-small-discriminator/resolve/main/tokenizer.json'
        ),
        'google/electra-base-discriminator': (
            'https://huggingface.co/google/electra-base-discriminator/resolve/main/tokenizer.json'
        ),
        'google/electra-large-discriminator': (
            'https://huggingface.co/google/electra-large-discriminator/resolve/main/tokenizer.json'
        ),
    },
}

lowercase						:      Tuple									= {
    'google/electra-small-generator': 512,
    'google/electra-base-generator': 512,
    'google/electra-large-generator': 512,
    'google/electra-small-discriminator': 512,
    'google/electra-base-discriminator': 512,
    'google/electra-large-discriminator': 512,
}

lowercase						:      str									= {
    'google/electra-small-generator': {'do_lower_case': True},
    'google/electra-base-generator': {'do_lower_case': True},
    'google/electra-large-generator': {'do_lower_case': True},
    'google/electra-small-discriminator': {'do_lower_case': True},
    'google/electra-base-discriminator': {'do_lower_case': True},
    'google/electra-large-discriminator': {'do_lower_case': True},
}




class 				lowerCamelCase__							(       __lowercase):




	'''simple docstring'''




	_A			=  VOCAB_FILES_NAMES
	_A			=  PRETRAINED_VOCAB_FILES_MAP
	_A			=  PRETRAINED_INIT_CONFIGURATION
	_A			=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	_A			=  ElectraTokenizer







	def __init__(      self	:Optional[Any]  ,     a	:List[Any]=None  ,     a	:Tuple=None  ,     a	:Tuple=True  ,     a	:Dict="[UNK]"  ,     a	:Optional[int]="[SEP]"  ,     a	:str="[PAD]"  ,     a	:Union[str, Any]="[CLS]"  ,     a	:int="[MASK]"  ,     a	:int=True  ,     a	:int=None  ,     **a	:List[str]  ,     )	->				str:
								super().__init__(
								    a  ,     tokenizer_file=a  ,     do_lower_case=a  ,     unk_token=a  ,     sep_token=a  ,     pad_token=a  ,     cls_token=a  ,     mask_token=a  ,     tokenize_chinese_chars=a  ,     strip_accents=a  ,     **a  ,     )

								__UpperCamelCase			:     Optional[Any]         =      json.loads(self.backend_tokenizer.normalizer.__getstate__()		)
								if (
								    normalizer_state.get("lowercase"  ,     a		) != do_lower_case
								    or normalizer_state.get("strip_accents"  ,     a		) != strip_accents
								    or normalizer_state.get("handle_chinese_chars"  ,     a		) != tokenize_chinese_chars
								):
															__UpperCamelCase			:     Union[str, Any]         =      getattr(a  ,     normalizer_state.pop("type"		)		)
															__UpperCamelCase			:     Union[str, Any]         =      do_lower_case
															__UpperCamelCase			:     Optional[int]         =      strip_accents
															__UpperCamelCase			:     str         =      tokenize_chinese_chars
															__UpperCamelCase			:     List[str]         =      normalizer_class(**a		)

								__UpperCamelCase			:     List[str]         =      do_lower_case







	def      _lowerCamelCase       (      self	:Any  ,     a	:Any  ,     a	:Union[str, Any]=None		)	->				Optional[Any]:
								__UpperCamelCase			:     Union[str, Any]         =      [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      _lowerCamelCase       (      self	:Optional[int]  ,     a	:List[int]  ,     a	:Optional[List[int]] = None		)	->				List[int]:
								__UpperCamelCase			:     int         =      [self.sep_token_id]
								__UpperCamelCase			:     List[Any]         =      [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      _lowerCamelCase       (      self	:int  ,     a	:str  ,     a	:Optional[str] = None		)	->				Tuple[str]:
								__UpperCamelCase			:     Optional[Any]         =      self._tokenizer.model.save(a  ,     name=a		)
								return tuple(a		)

import re
import string

import numpy as np

import datasets


lowercase						:      List[str]									= '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n'

lowercase						:      List[str]									= '\nArgs:\n    predictions: List of predicted texts.\n    references: List of reference texts.\n    regexes_to_ignore: List, defaults to None. Regex expressions of characters to\n        ignore when calculating the exact matches. Note: these regexes are removed\n        from the input data before the changes based on the options below (e.g. ignore_case,\n        ignore_punctuation, ignore_numbers) are applied.\n    ignore_case: Boolean, defaults to False. If true, turns everything\n        to lowercase so that capitalization differences are ignored.\n    ignore_punctuation: Boolean, defaults to False. If true, removes all punctuation before\n        comparing predictions and references.\n    ignore_numbers: Boolean, defaults to False. If true, removes all punctuation before\n        comparing predictions and references.\nReturns:\n    exact_match: Dictionary containing exact_match rate. Possible values are between 0.0 and 100.0, inclusive.\nExamples:\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds)\n    >>> print(round(results["exact_match"], 1))\n    25.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell"], ignore_case=True, ignore_punctuation=True)\n    >>> print(round(results["exact_match"], 1))\n    50.0\n\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell", "YELL"], ignore_case=True, ignore_punctuation=True)\n    >>> print(round(results["exact_match"], 1))\n    75.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell", "YELL"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)\n    >>> print(round(results["exact_match"], 1))\n    100.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["The cat sat on the mat.", "Theaters are great.", "It\'s like comparing oranges and apples."]\n    >>> preds = ["The cat sat on the mat?", "Theaters are great.", "It\'s like comparing apples and oranges."]\n    >>> results = exact_match.compute(references=refs, predictions=preds)\n    >>> print(round(results["exact_match"], 1))\n    33.3\n\n'

lowercase						:      List[str]									= '\n'




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




	'''simple docstring'''




	def      _lowerCamelCase       (      self	:Dict		)	->				Optional[Any]:
								return datasets.MetricInfo(
								    description=_DESCRIPTION  ,     citation=_CITATION  ,     inputs_description=_KWARGS_DESCRIPTION  ,     features=datasets.Features(
								        {
								            "predictions": datasets.Value("string"  ,     id="sequence"		),
								            "references": datasets.Value("string"  ,     id="sequence"		),
								        }		)  ,     reference_urls=[]  ,     )







	def      _lowerCamelCase       (      self	:int  ,     a	:Optional[Any]  ,     a	:Dict  ,     a	:Optional[int]=None  ,     a	:int=False  ,     a	:Tuple=False  ,     a	:Optional[int]=False  ,     )	->				Any:
								if regexes_to_ignore is not None:
															for s in regexes_to_ignore:
																						__UpperCamelCase			:     List[Any]         =      np.array([re.sub(a  ,     ""  ,     a		) for x in predictions]		)
																						__UpperCamelCase			:     Optional[Any]         =      np.array([re.sub(a  ,     ""  ,     a		) for x in references]		)
								else:
															__UpperCamelCase			:     Optional[int]         =      np.asarray(a		)
															__UpperCamelCase			:     List[str]         =      np.asarray(a		)

								if ignore_case:
															__UpperCamelCase			:     Optional[int]         =      np.char.lower(a		)
															__UpperCamelCase			:     str         =      np.char.lower(a		)

								if ignore_punctuation:
															__UpperCamelCase			:     Tuple         =      string.punctuation.maketrans(""  ,     ""  ,     string.punctuation		)
															__UpperCamelCase			:     int         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     str         =      np.char.translate(a  ,     table=a		)

								if ignore_numbers:
															__UpperCamelCase			:     List[str]         =      string.digits.maketrans(""  ,     ""  ,     string.digits		)
															__UpperCamelCase			:     Tuple         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     Union[str, Any]         =      np.char.translate(a  ,     table=a		)

								__UpperCamelCase			:     List[Any]         =      predictions == references

								return {"exact_match": np.mean(a		) * 1_0_0}