

import re
import string

import numpy as np

import datasets


lowerCAmelCase							:  str            =						"""
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.
"""

lowerCAmelCase							:  Optional[Any]            =						"""
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

"""

lowerCAmelCase							:  List[str]            =						"""
"""



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




			"""simple docstring"""







			def 	_SCREAMING_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 	_SCREAMING_SNAKE_CASE      (			self  :					List[Any]       ,						lowerCAmelCase__  :					Tuple       ,						lowerCAmelCase__  :					List[Any]       ,						lowerCAmelCase__  :					int=None       ,						lowerCAmelCase__  :					Dict=False       ,						lowerCAmelCase__  :					str=False       ,						lowerCAmelCase__  :					Any=False       ,						):
									if regexes_to_ignore is not None:
															for s in regexes_to_ignore:
																					SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	np.array([re.sub(lowerCAmelCase__       ,						""       ,						lowerCAmelCase__) for x in predictions])
																					SCREAMING_SNAKE_CASE_:			Tuple  		=	np.array([re.sub(lowerCAmelCase__       ,						""       ,						lowerCAmelCase__) for x in references])
									else:
															SCREAMING_SNAKE_CASE_:			List[str]  		=	np.asarray(lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:			List[Any]  		=	np.asarray(lowerCAmelCase__)

									if ignore_case:
															SCREAMING_SNAKE_CASE_:			Dict  		=	np.char.lower(lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:			Any  		=	np.char.lower(lowerCAmelCase__)

									if ignore_punctuation:
															SCREAMING_SNAKE_CASE_:			Dict  		=	string.punctuation.maketrans(""       ,						""       ,						string.punctuation)
															SCREAMING_SNAKE_CASE_:			str  		=	np.char.translate(lowerCAmelCase__       ,						table=lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:			Any  		=	np.char.translate(lowerCAmelCase__       ,						table=lowerCAmelCase__)

									if ignore_numbers:
															SCREAMING_SNAKE_CASE_:			Tuple  		=	string.digits.maketrans(""       ,						""       ,						string.digits)
															SCREAMING_SNAKE_CASE_:			int  		=	np.char.translate(lowerCAmelCase__       ,						table=lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:			Tuple  		=	np.char.translate(lowerCAmelCase__       ,						table=lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			List[Any]  		=	predictions == references

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









from ...configuration_utils import PretrainedConfig
from ...utils import logging


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

lowerCAmelCase							:  int            =						{
    """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.json""",
    """google/fnet-large""": """https://huggingface.co/google/fnet-large/resolve/main/config.json"""
    # See all FNet models at https://huggingface.co/models?filter=fnet
}



class   __lowercase    (			UpperCAmelCase_     ):




			"""simple docstring"""







			_UpperCAmelCase       :							int      							=					'''fnet'''



			def __init__(			self  :					Optional[Any]       ,						lowerCAmelCase__  :					List[str]=3_2000       ,						lowerCAmelCase__  :					Union[str, Any]=768       ,						lowerCAmelCase__  :					Optional[Any]=12       ,						lowerCAmelCase__  :					Tuple=3072       ,						lowerCAmelCase__  :					Any="gelu_new"       ,						lowerCAmelCase__  :					Union[str, Any]=0.1       ,						lowerCAmelCase__  :					Optional[Any]=512       ,						lowerCAmelCase__  :					int=4       ,						lowerCAmelCase__  :					List[Any]=0.02       ,						lowerCAmelCase__  :					Union[str, Any]=1E-12       ,						lowerCAmelCase__  :					Optional[int]=False       ,						lowerCAmelCase__  :					Any=512       ,						lowerCAmelCase__  :					Optional[int]=3       ,						lowerCAmelCase__  :					int=1       ,						lowerCAmelCase__  :					List[Any]=2       ,						**lowerCAmelCase__  :					Optional[int]       ,						):
									super().__init__(pad_token_id=lowerCAmelCase__       ,						bos_token_id=lowerCAmelCase__       ,						eos_token_id=lowerCAmelCase__       ,						**lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			str  		=	vocab_size
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	max_position_embeddings
									SCREAMING_SNAKE_CASE_:			Tuple  		=	hidden_size
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	num_hidden_layers
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	intermediate_size
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	hidden_act
									SCREAMING_SNAKE_CASE_:			Any  		=	hidden_dropout_prob
									SCREAMING_SNAKE_CASE_:			int  		=	initializer_range
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	type_vocab_size
									SCREAMING_SNAKE_CASE_:			int  		=	layer_norm_eps
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	use_tpu_fourier_optimizations
									SCREAMING_SNAKE_CASE_:			int  		=	tpu_short_seq_length






