






from math import factorial




class 				lowerCamelCase__							:




	'''simple docstring'''




	def __init__(      self	:Union[str, Any]  ,     a	:List[Any]  ,     a	:Optional[Any]		)	->				Dict:
								__UpperCamelCase			:     Dict         =      real
								if isinstance(lowercase__  ,     lowercase__		):
															__UpperCamelCase			:     Dict         =      [1] * rank
								else:
															__UpperCamelCase			:     int         =      rank







	def __repr__(      self	:str		)	->				Optional[Any]:
								return (
								    f'{self.real}+'
								    f'{"+".join(str(lowercase__		)+"E"+str(n+1		)for n,dual in enumerate(self.duals		)		)}'
								)







	def      _lowerCamelCase       (      self	:str		)	->				Tuple:
								__UpperCamelCase			:     Optional[Any]         =      self.duals.copy()
								while cur[-1] == 0:
															cur.pop(-1		)
								return Dual(self.real  ,     lowercase__		)







	def __add__(      self	:Union[str, Any]  ,     a	:Dict		)	->				List[str]:






								if not isinstance(lowercase__  ,     lowercase__		):
															return Dual(self.real + other  ,     self.duals		)
								__UpperCamelCase			:     Dict         =      self.duals.copy()
								__UpperCamelCase			:     Tuple         =      other.duals.copy()
								if len(lowercase__		) > len(lowercase__		):
															o_dual.extend([1] * (len(lowercase__		) - len(lowercase__		))		)
								elif len(lowercase__		) < len(lowercase__		):
															s_dual.extend([1] * (len(lowercase__		) - len(lowercase__		))		)
								__UpperCamelCase			:     List[Any]         =      []
								for i in range(len(lowercase__		)		):
															new_duals.append(s_dual[i] + o_dual[i]		)
								return Dual(self.real + other.real  ,     lowercase__		)

	_A			=  __add__







	def __sub__(      self	:Optional[Any]  ,     a	:Dict		)	->				Optional[int]:
								return self + other * -1







	def __mul__(      self	:Tuple  ,     a	:Any		)	->				Optional[Any]:






								if not isinstance(lowercase__  ,     lowercase__		):
															__UpperCamelCase			:     Union[str, Any]         =      []
															for i in self.duals:
																						new_duals.append(i * other		)
															return Dual(self.real * other  ,     lowercase__		)
								__UpperCamelCase			:     Optional[Any]         =      [0] * (len(self.duals		) + len(other.duals		) + 1)
								for i, item in enumerate(self.duals		):
															for j, jtem in enumerate(other.duals		):
																						new_duals[i + j + 1] += item * jtem
								for k in range(len(self.duals		)		):
															new_duals[k] += self.duals[k] * other.real
								for index in range(len(other.duals		)		):
															new_duals[index] += other.duals[index] * self.real
								return Dual(self.real * other.real  ,     lowercase__		)

	_A			=  __mul__







	def __truediv__(      self	:Optional[Any]  ,     a	:Optional[Any]		)	->				Optional[Any]:






								if not isinstance(lowercase__  ,     lowercase__		):
															__UpperCamelCase			:     Union[str, Any]         =      []
															for i in self.duals:
																						new_duals.append(i / other		)
															return Dual(self.real / other  ,     lowercase__		)
								raise ValueError







	def __floordiv__(      self	:List[Any]  ,     a	:Tuple		)	->				Dict:






								if not isinstance(lowercase__  ,     lowercase__		):
															__UpperCamelCase			:     Optional[Any]         =      []
															for i in self.duals:
																						new_duals.append(i // other		)
															return Dual(self.real // other  ,     lowercase__		)
								raise ValueError







	def __pow__(      self	:Optional[Any]  ,     a	:List[str]		)	->				List[Any]:






								if n < 0 or isinstance(lowercase__  ,     lowercase__		):
															raise ValueError("power must be a positive integer"		)
								if n == 0:
															return 1
								if n == 1:
															return self
								__UpperCamelCase			:     Optional[Any]         =      self
								for _ in range(n - 1		):
															x *= self
								return x




def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    Union[str, Any]		,						_lowerCamelCase				:    int		,						_lowerCamelCase				:    int)      ->					Any:






							'''simple docstring'''





							if not callable(SCREAMING_SNAKE_CASE_):
														raise ValueError("differentiate() requires a function as input for func")
							if not isinstance(SCREAMING_SNAKE_CASE_		,						(float, int)):
														raise ValueError("differentiate() requires a float as input for position")
							if not isinstance(SCREAMING_SNAKE_CASE_		,						SCREAMING_SNAKE_CASE_):
														raise ValueError("differentiate() requires an int as input for order")
							__UpperCamelCase			:     List[str]         =      Dual(SCREAMING_SNAKE_CASE_		,						1)
							__UpperCamelCase			:     Dict         =      func(SCREAMING_SNAKE_CASE_)
							if order == 0:
														return result.real
							return result.duals[order - 1] * factorial(SCREAMING_SNAKE_CASE_)


if __name__ == "__main__":
		import doctest

		doctest.testmod()




		def 			_SCREAMING_SNAKE_CASE      (	_lowerCamelCase				:    int)      ->					Union[str, Any]:






									'''simple docstring'''





									return y**2 * y**4




		print(differentiate(f, 9, 2))

import re
import string

import numpy as np

import datasets


lowercase						:      List[str]									= '\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'

lowercase						:      List[str]									= '\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'

lowercase						:      List[str]									= '\n'




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




	'''simple docstring'''




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

								if ignore_case:
															__UpperCamelCase			:     Optional[int]         =      np.char.lower(a		)
															__UpperCamelCase			:     str         =      np.char.lower(a		)

								if ignore_punctuation:
															__UpperCamelCase			:     Tuple         =      string.punctuation.maketrans(""  ,     ""  ,     string.punctuation		)
															__UpperCamelCase			:     int         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     str         =      np.char.translate(a  ,     table=a		)

								if ignore_numbers:
															__UpperCamelCase			:     List[str]         =      string.digits.maketrans(""  ,     ""  ,     string.digits		)
															__UpperCamelCase			:     Tuple         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     Union[str, Any]         =      np.char.translate(a  ,     table=a		)

								__UpperCamelCase			:     List[Any]         =      predictions == references

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