



"""simple docstring"""


import os
import sys

__A   :							int										=   os.path.join(os.path.dirname(__file__), "src")
sys.path.append(SRC_DIR)


from transformers import (
    AutoConfig,
    AutoModel,
    AutoModelForCausalLM,
    AutoModelForMaskedLM,
    AutoModelForQuestionAnswering,
    AutoModelForSequenceClassification,
    AutoTokenizer,
    add_start_docstrings,
)


__A   :							List[Any]										=   [
    "torch",
    "numpy",
    "tokenizers",
    "filelock",
    "requests",
    "tqdm",
    "regex",
    "sentencepiece",
    "sacremoses",
    "importlib_metadata",
    "huggingface_hub",
]







@add_start_docstrings(AutoConfig.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						Any					,     **_SCREAMING_SNAKE_CASE   :						List[Any]				):






				'''simple docstring'''



				return AutoConfig.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoTokenizer.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						str					,     **_SCREAMING_SNAKE_CASE   :						List[Any]				):






				'''simple docstring'''



				return AutoTokenizer.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoModel.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						Tuple					,     **_SCREAMING_SNAKE_CASE   :						Dict				):






				'''simple docstring'''



				return AutoModel.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoModelForCausalLM.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						List[Any]					,     **_SCREAMING_SNAKE_CASE   :						Tuple				):






				'''simple docstring'''



				return AutoModelForCausalLM.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoModelForMaskedLM.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						List[Any]					,     **_SCREAMING_SNAKE_CASE   :						List[Any]				):






				'''simple docstring'''



				return AutoModelForMaskedLM.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoModelForSequenceClassification.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						Any					,     **_SCREAMING_SNAKE_CASE   :						int				):






				'''simple docstring'''



				return AutoModelForSequenceClassification.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)







@add_start_docstrings(AutoModelForQuestionAnswering.__doc__				)
def  lowercase	(      *_SCREAMING_SNAKE_CASE   :						Dict					,     **_SCREAMING_SNAKE_CASE   :						Dict				):






				'''simple docstring'''



				return AutoModelForQuestionAnswering.from_pretrained(*_lowerCamelCase					,     **_lowerCamelCase				)








"""simple docstring"""


import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


__A   :							Any										=   "\\n@article{hendrycksmath2021,\n  title={Measuring Mathematical Problem Solving With the MATH Dataset},\n  author={Dan Hendrycks\n    and Collin Burns\n    and Saurav Kadavath\n    and Akul Arora\n    and Steven Basart\n    and Eric Tang\n    and Dawn Song\n    and Jacob Steinhardt},\n  journal={arXiv preprint arXiv:2103.03874},\n  year={2021}\n}\n"


__A   :							Optional[Any]										=   "\\nThis metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.\nIt first canonicalizes the inputs (e.g., converting \"1/2\" to \"\\frac{1}{2}\") and then computes accuracy.\n"


__A   :							Tuple										=   r"\nCalculates accuracy after canonicalizing inputs.\n\nArgs:\n    predictions: list of predictions to score. Each prediction\n        is a string that contains natural language and LaTex.\n    references: list of reference for each prediction. Each\n        reference is a string that contains natural language\n        and LaTex.\nReturns:\n    accuracy: accuracy after canonicalizing inputs\n        (e.g., converting \"1/2\" to \"\\frac{1}{2}\")\n\nExamples:\n    >>> metric = datasets.load_metric(\"competition_math\")\n    >>> results = metric.compute(references=[\"\\frac{1}{2}\"], predictions=[\"1/2\"])\n    >>> print(results)\n    {'accuracy': 1.0}\n"
@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION			,							_KWARGS_DESCRIPTION)
class 			_a (					datasets.Metric):
			"""simple docstring"""



			def  lowercase__						(		self     :    List[Any]   )->Dict:
							return datasets.MetricInfo(
							    description=_DESCRIPTION				,   citation=_CITATION				,   inputs_description=_KWARGS_DESCRIPTION				,   features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''string'''   ),
							            '''references''': datasets.Value('''string'''   ),
							        }   )				,   homepage='''https://github.com/hendrycks/math'''				,   codebase_urls=['''https://github.com/hendrycks/math''']				,   )



			def  lowercase__						(		self     :    int				,   __UpperCamelCase     :    List[str]				,   __UpperCamelCase     :    Union[str, Any]   )->Tuple:
							_UpperCAmelCase					=    0.0
							for i, j in zip(__UpperCamelCase				,   __UpperCamelCase   ):
											n_correct += 1.0 if math_equivalence.is_equiv(__UpperCamelCase				,   __UpperCamelCase   ) else 0.0
							_UpperCAmelCase					=    n_correct / len(__UpperCamelCase   )
							return {
							    "accuracy": accuracy,
							}



