






"""simple docstring"""
from ...processing_utils import ProcessorMixin



class   SCREAMING_SNAKE_CASE	(					_SCREAMING_SNAKE_CASE    ):





	"""simple docstring"""




	_A							:					Optional[int] 			=					"""WhisperFeatureExtractor"""
	_A							:					List[str] 			=					"""WhisperTokenizer"""





	def __init__(self  ,  lowerCAmelCase_  ,  lowerCAmelCase_				):
		super().__init__(lowerCAmelCase_  ,  lowerCAmelCase_				)
		A_		:    Any						     = self.feature_extractor
		A_		:    Dict						     = False





	def  lowerCamelCase(self  ,  lowerCAmelCase_=None  ,  lowerCAmelCase_=None  ,  lowerCAmelCase_=True				):
		return self.tokenizer.get_decoder_prompt_ids(task=lowerCAmelCase_  ,  language=lowerCAmelCase_  ,  no_timestamps=lowerCAmelCase_				)





	def __call__(self  ,  *lowerCAmelCase_  ,  **lowerCAmelCase_				):
		# For backward compatibility
		if self._in_target_context_manager:
			return self.current_processor(*lowerCAmelCase_  ,  **lowerCAmelCase_				)

		A_		:    Any						     = kwargs.pop("""audio"""  ,  lowerCAmelCase_				)
		A_		:    Dict						     = kwargs.pop("""sampling_rate"""  ,  lowerCAmelCase_				)
		A_		:    int						     = kwargs.pop("""text"""  ,  lowerCAmelCase_				)
		if len(lowerCAmelCase_				) > 0:
			A_		:    Dict						     = args[0]
			A_		:    int						     = args[1:]

		if audio is None and text is None:
			raise ValueError("""You need to specify either an `audio` or `text` input to process."""				)

		if audio is not None:
			A_		:    Optional[Any]						     = self.feature_extractor(lowerCAmelCase_  ,  *lowerCAmelCase_  ,  sampling_rate=lowerCAmelCase_  ,  **lowerCAmelCase_				)
		if text is not None:
			A_		:    int						     = self.tokenizer(lowerCAmelCase_  ,  **lowerCAmelCase_				)

		if text is None:
			return inputs

		elif audio is None:
			return encodings
		else:
			A_		:    Optional[Any]						     = encodings["""input_ids"""]
			return inputs





	def  lowerCamelCase(self  ,  *lowerCAmelCase_  ,  **lowerCAmelCase_				):
		return self.tokenizer.batch_decode(*lowerCAmelCase_  ,  **lowerCAmelCase_				)





	def  lowerCamelCase(self  ,  *lowerCAmelCase_  ,  **lowerCAmelCase_				):
		return self.tokenizer.decode(*lowerCAmelCase_  ,  **lowerCAmelCase_				)





	def  lowerCamelCase(self  ,  lowerCAmelCase_  ,  lowerCAmelCase_="np"				):
		return self.tokenizer.get_prompt_ids(lowerCAmelCase_  ,  return_tensors=lowerCAmelCase_				)









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

import datasets


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


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


_lowerCAmelCase       =				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   SCREAMING_SNAKE_CASE	(					datasets.Metric    ):





	"""simple docstring"""




	def  lowerCamelCase(self				):
		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  lowerCamelCase(self  ,  lowerCAmelCase_  ,  lowerCAmelCase_				):
		A_		:    Optional[Any]						     = 0.0
		for i, j in zip(lowerCAmelCase_  ,  lowerCAmelCase_				):
			n_correct += 1.0 if math_equivalence.is_equiv(lowerCAmelCase_  ,  lowerCAmelCase_				) else 0.0
		A_		:    List[str]						     = n_correct / len(lowerCAmelCase_				)
		return {
		    "accuracy": accuracy,
		}

