


import re
import string

import numpy as np

import datasets


_UpperCAmelCase			:  Union[str, 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.
"""

_UpperCAmelCase			:  int     ="""
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

"""

_UpperCAmelCase			:  Optional[Any]     ="""
"""







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







						'''simple docstring'''




						def 						lowercase_ (				self							)					->    Union[str, 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 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase=None   ,						__lowercase=False   ,						__lowercase=False   ,						__lowercase=False   ,						)					->    Optional[Any]:
										if regexes_to_ignore is not None:
														for s in regexes_to_ignore:
																		lowerCAmelCase_ :      Union[str, Any]    				=				np.array([re.sub(__lowercase   ,						''''''   ,						__lowercase							) for x in predictions]							)
																		lowerCAmelCase_ :      Dict    				=				np.array([re.sub(__lowercase   ,						''''''   ,						__lowercase							) for x in references]							)
										else:
														lowerCAmelCase_ :      Any    				=				np.asarray(__lowercase							)
														lowerCAmelCase_ :      Dict    				=				np.asarray(__lowercase							)

										if ignore_case:
														lowerCAmelCase_ :      int    				=				np.char.lower(__lowercase							)
														lowerCAmelCase_ :      Tuple    				=				np.char.lower(__lowercase							)

										if ignore_punctuation:
														lowerCAmelCase_ :      int    				=				string.punctuation.maketrans(''''''   ,						''''''   ,						string.punctuation							)
														lowerCAmelCase_ :      int    				=				np.char.translate(__lowercase   ,						table=__lowercase							)
														lowerCAmelCase_ :      Optional[Any]    				=				np.char.translate(__lowercase   ,						table=__lowercase							)

										if ignore_numbers:
														lowerCAmelCase_ :      str    				=				string.digits.maketrans(''''''   ,						''''''   ,						string.digits							)
														lowerCAmelCase_ :      Union[str, Any]    				=				np.char.translate(__lowercase   ,						table=__lowercase							)
														lowerCAmelCase_ :      Any    				=				np.char.translate(__lowercase   ,						table=__lowercase							)

										lowerCAmelCase_ :      Optional[int]    				=				predictions == references

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



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


_UpperCAmelCase			:  Union[str, Any]     ={
    """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LlamaConfig"""],
}

try:
						if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  Optional[Any]     =["""LlamaTokenizer"""]

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  Optional[int]     =["""LlamaTokenizerFast"""]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						_UpperCAmelCase			:  Tuple     =[
						    """LlamaForCausalLM""",
						    """LlamaModel""",
						    """LlamaPreTrainedModel""",
						    """LlamaForSequenceClassification""",
						]


if TYPE_CHECKING:
						from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

						try:
												if not is_sentencepiece_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_llama import LlamaTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_llama_fast import LlamaTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
						import sys

						_UpperCAmelCase			:  List[Any]     =_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)