
"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

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


A__ :       Any				= logging.get_logger(__name__)

A__ :       Union[str, Any]				= {
    'distilbert-base-uncased': 'https://huggingface.co/distilbert-base-uncased/resolve/main/config.json',
    'distilbert-base-uncased-distilled-squad': (
        'https://huggingface.co/distilbert-base-uncased-distilled-squad/resolve/main/config.json'
    ),
    'distilbert-base-cased': 'https://huggingface.co/distilbert-base-cased/resolve/main/config.json',
    'distilbert-base-cased-distilled-squad': (
        'https://huggingface.co/distilbert-base-cased-distilled-squad/resolve/main/config.json'
    ),
    'distilbert-base-german-cased': 'https://huggingface.co/distilbert-base-german-cased/resolve/main/config.json',
    'distilbert-base-multilingual-cased': (
        'https://huggingface.co/distilbert-base-multilingual-cased/resolve/main/config.json'
    ),
    'distilbert-base-uncased-finetuned-sst-2-english': (
        'https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json'
    ),
}


class       __magic_name__							(							SCREAMING_SNAKE_CASE__			):
       UpperCamelCase_ =		"distilbert"
       UpperCamelCase_ =		{
           "hidden_size": "dim",
           "num_attention_heads": "n_heads",
           "num_hidden_layers": "n_layers",
       }
       def __init__(  self			,					A_=3_0522			,					A_=512			,					A_=False			,					A_=6			,					A_=12			,					A_=768			,					A_=4 * 768			,					A_=0.1			,					A_=0.1			,					A_="gelu"			,					A_=0.02			,					A_=0.1			,					A_=0.2			,					A_=0			,					**A_			,					)  ->						int:





         """simple docstring"""




         _lowercase:      Any   			=  vocab_size
         _lowercase:      Union[str, Any]   			=  max_position_embeddings
         _lowercase:      Tuple   			=  sinusoidal_pos_embds
         _lowercase:      Dict   			=  n_layers
         _lowercase:      Union[str, Any]   			=  n_heads
         _lowercase:      Optional[int]   			=  dim
         _lowercase:      Union[str, Any]   			=  hidden_dim
         _lowercase:      Union[str, Any]   			=  dropout
         _lowercase:      str   			=  attention_dropout
         _lowercase:      int   			=  activation
         _lowercase:      List[str]   			=  initializer_range
         _lowercase:      List[Any]   			=  qa_dropout
         _lowercase:      Union[str, Any]   			=  seq_classif_dropout
         super().__init__(**_lowerCAmelCase			,					pad_token_id=_lowerCAmelCase							)


class       __magic_name__							(							SCREAMING_SNAKE_CASE__			):
       @property
       def 				lowercase_				(  self							)  ->						Mapping[str, Mapping[int, str]]:





         """simple docstring"""




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







'''simple docstring'''


import re
import string

import numpy as np

import datasets


_SCREAMING_SNAKE_CASE									=				"\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"

_SCREAMING_SNAKE_CASE									=				"\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"

_SCREAMING_SNAKE_CASE									=				"\n"

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




 def 				_snake_case (						self		)     ->				List[str]:
     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 				_snake_case (						self      ,  _lowerCAmelCase      ,  _lowerCAmelCase      ,  _lowerCAmelCase=None      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=False      ,  _lowerCAmelCase=False      ,  )     ->				str:
     if regexes_to_ignore is not None:
         for s in regexes_to_ignore:
             _lowerCAmelCase						      =   np.array([re.sub(_lowerCAmelCase      ,  ""      ,  _lowerCAmelCase		) for x in predictions]		)
             _lowerCAmelCase						      =   np.array([re.sub(_lowerCAmelCase      ,  ""      ,  _lowerCAmelCase		) for x in references]		)
     else:
         _lowerCAmelCase						      =   np.asarray(_lowerCAmelCase		)
         _lowerCAmelCase						      =   np.asarray(_lowerCAmelCase		)

     if ignore_case:
         _lowerCAmelCase						      =   np.char.lower(_lowerCAmelCase		)
         _lowerCAmelCase						      =   np.char.lower(_lowerCAmelCase		)

     if ignore_punctuation:
         _lowerCAmelCase						      =   string.punctuation.maketrans(""      ,  ""      ,  string.punctuation		)
         _lowerCAmelCase						      =   np.char.translate(_lowerCAmelCase      ,  table=_lowerCAmelCase		)
         _lowerCAmelCase						      =   np.char.translate(_lowerCAmelCase      ,  table=_lowerCAmelCase		)

     if ignore_numbers:
         _lowerCAmelCase						      =   string.digits.maketrans(""      ,  ""      ,  string.digits		)
         _lowerCAmelCase						      =   np.char.translate(_lowerCAmelCase      ,  table=_lowerCAmelCase		)
         _lowerCAmelCase						      =   np.char.translate(_lowerCAmelCase      ,  table=_lowerCAmelCase		)

     _lowerCAmelCase						      =   predictions == references

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


