





import re
import string

import numpy as np

import datasets


lowercase      :       Optional[Any]									=  """
Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.
"""

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

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    50.0


    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    75.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)
    >>> print(round(results[\"exact_match\"], 1))
    100.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"The cat sat on the mat.\", \"Theaters are great.\", \"It's like comparing oranges and apples.\"]
    >>> preds = [\"The cat sat on the mat?\", \"Theaters are great.\", \"It's like comparing apples and oranges.\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    33.3

"""

lowercase      :       Optional[Any]									=  """
"""





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




   """simple docstring"""



   def 							__lowercase		(					self)			->						Tuple:







          '''simple docstring'''

          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 							__lowercase		(					self					,  lowercase					,  lowercase					,  lowercase=None					,  lowercase=False					,  lowercase=False					,  lowercase=False					,  )			->						Tuple:







          '''simple docstring'''

          if regexes_to_ignore is not None:
                 for s in regexes_to_ignore:
                        a__						:	Optional[int] =				np.array([re.sub(lowercase					,  ''					,  lowercase) for x in predictions])
                        a__						:	Tuple =				np.array([re.sub(lowercase					,  ''					,  lowercase) for x in references])
          else:
                 a__						:	Dict =				np.asarray(lowercase)
                 a__						:	List[Any] =				np.asarray(lowercase)

          if ignore_case:
                 a__						:	Optional[Any] =				np.char.lower(lowercase)
                 a__						:	Dict =				np.char.lower(lowercase)

          if ignore_punctuation:
                 a__						:	int =				string.punctuation.maketrans(''					,  ''					,  string.punctuation)
                 a__						:	Tuple =				np.char.translate(lowercase					,  table=lowercase)
                 a__						:	List[str] =				np.char.translate(lowercase					,  table=lowercase)

          if ignore_numbers:
                 a__						:	List[Any] =				string.digits.maketrans(''					,  ''					,  string.digits)
                 a__						:	Dict =				np.char.translate(lowercase					,  table=lowercase)
                 a__						:	Tuple =				np.char.translate(lowercase					,  table=lowercase)

          a__						:	int =				predictions == references

          return {"exact_match": np.mean(lowercase) * 100}



from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__a  :     Optional[int]       =  logging.get_logger(__name__)

__a  :     Tuple       =  {
    """facebook/data2vec-text-base""": """https://huggingface.co/data2vec/resolve/main/config.json""",
}




class    _UpperCamelCase      (						_UpperCAmelCase ):


			"""simple docstring"""






			__a  : Dict			 =						'''data2vec-text'''





			def __init__(   self      ,   lowerCAmelCase__=3_05_22      ,   lowerCAmelCase__=7_68      ,   lowerCAmelCase__=12      ,   lowerCAmelCase__=12      ,   lowerCAmelCase__=30_72      ,   lowerCAmelCase__="gelu"      ,   lowerCAmelCase__=0.1      ,   lowerCAmelCase__=0.1      ,   lowerCAmelCase__=5_12      ,   lowerCAmelCase__=2      ,   lowerCAmelCase__=0.02      ,   lowerCAmelCase__=1E-12      ,   lowerCAmelCase__=1      ,   lowerCAmelCase__=0      ,   lowerCAmelCase__=2      ,   lowerCAmelCase__="absolute"      ,   lowerCAmelCase__=True      ,   lowerCAmelCase__=None      ,   **lowerCAmelCase__      ,   )     ->					Any:

							'''simple docstring'''


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

							__lowercase 			=							vocab_size
							__lowercase 			=							hidden_size
							__lowercase 			=							num_hidden_layers
							__lowercase 			=							num_attention_heads
							__lowercase 			=							hidden_act
							__lowercase 			=							intermediate_size
							__lowercase 			=							hidden_dropout_prob
							__lowercase 			=							attention_probs_dropout_prob
							__lowercase 			=							max_position_embeddings
							__lowercase 			=							type_vocab_size
							__lowercase 			=							initializer_range
							__lowercase 			=							layer_norm_eps
							__lowercase 			=							position_embedding_type
							__lowercase 			=							use_cache
							__lowercase 			=							classifier_dropout




class    _UpperCamelCase      (						_UpperCAmelCase ):


			"""simple docstring"""






			@property
			def        _SCREAMING_SNAKE_CASE			(   self						)     ->					Mapping[str, Mapping[int, str]]:

							'''simple docstring'''


							if self.task == "multiple-choice":
											__lowercase 			=							{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
							else:
											__lowercase 			=							{0: '''batch''', 1: '''sequence'''}
							return OrderedDict(
							    [
							        ('''input_ids''', dynamic_axis),
							        ('''attention_mask''', dynamic_axis),
							    ]						)