






"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_snake_case        =  logging.get_logger(__name__)

_snake_case        =  {
    'facebook/xmod-base': 'https://huggingface.co/facebook/xmod-base/resolve/main/config.json',
    'facebook/xmod-large-prenorm': 'https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json',
    'facebook/xmod-base-13-125k': 'https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json',
    'facebook/xmod-base-30-125k': 'https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json',
    'facebook/xmod-base-30-195k': 'https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json',
    'facebook/xmod-base-60-125k': 'https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json',
    'facebook/xmod-base-60-265k': 'https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json',
    'facebook/xmod-base-75-125k': 'https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json',
    'facebook/xmod-base-75-269k': 'https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json',
}






class 			UpperCamelCase     (      A_ ):
 UpperCamelCase   :			Tuple     =   "xmod"


 def __init__(	self						:		Optional[int]				,		UpperCAmelCase__						:		Any=30522				,		UpperCAmelCase__						:		Optional[Any]=768				,		UpperCAmelCase__						:		Dict=12				,		UpperCAmelCase__						:		List[Any]=12				,		UpperCAmelCase__						:		List[Any]=3072				,		UpperCAmelCase__						:		Dict="gelu"				,		UpperCAmelCase__						:		Tuple=0.1				,		UpperCAmelCase__						:		List[Any]=0.1				,		UpperCAmelCase__						:		Any=512				,		UpperCAmelCase__						:		Tuple=2				,		UpperCAmelCase__						:		Dict=0.0_2				,		UpperCAmelCase__						:		List[str]=1E-12				,		UpperCAmelCase__						:		Optional[int]=1				,		UpperCAmelCase__						:		str=0				,		UpperCAmelCase__						:		Union[str, Any]=2				,		UpperCAmelCase__						:		Optional[int]="absolute"				,		UpperCAmelCase__						:		int=True				,		UpperCAmelCase__						:		Optional[int]=None				,		UpperCAmelCase__						:		List[Any]=False				,		UpperCAmelCase__						:		int=2				,		UpperCAmelCase__						:		Union[str, Any]=False				,		UpperCAmelCase__						:		Optional[Any]=True				,		UpperCAmelCase__						:		str=True				,		UpperCAmelCase__						:		Tuple=("en_XX",)				,		UpperCAmelCase__						:		Union[str, Any]=None				,		**UpperCAmelCase__						:		int				,		)   ->			List[str]:
   super().__init__(pad_token_id=snake_case__				,		bos_token_id=snake_case__				,		eos_token_id=snake_case__				,		**snake_case__				)

   _a    :			int			 =      vocab_size
   _a    :			Optional[Any]			 =      hidden_size
   _a    :			Dict			 =      num_hidden_layers
   _a    :			Tuple			 =      num_attention_heads
   _a    :			List[Any]			 =      hidden_act
   _a    :			int			 =      intermediate_size
   _a    :			Optional[int]			 =      hidden_dropout_prob
   _a    :			List[str]			 =      attention_probs_dropout_prob
   _a    :			Optional[int]			 =      max_position_embeddings
   _a    :			Union[str, Any]			 =      type_vocab_size
   _a    :			List[Any]			 =      initializer_range
   _a    :			Union[str, Any]			 =      layer_norm_eps
   _a    :			List[str]			 =      position_embedding_type
   _a    :			Dict			 =      use_cache
   _a    :			List[str]			 =      classifier_dropout
   _a    :			Tuple			 =      pre_norm
   _a    :			List[Any]			 =      adapter_reduction_factor
   _a    :			Dict			 =      adapter_layer_norm
   _a    :			Optional[int]			 =      adapter_reuse_layer_norm
   _a    :			Optional[Any]			 =      ln_before_adapter
   _a    :			Any			 =      list(snake_case__				)
   _a    :			Tuple			 =      default_language







class 			UpperCamelCase     (      A_ ):


 @property
 def _lowercase      (	self						:		List[Any]				)   ->			Mapping[str, Mapping[int, str]]:


   if self.task == "multiple-choice":
     _a    :			str			 =      {0: "batch", 1: "choice", 2: "sequence"}
   else:
     _a    :			int			 =      {0: "batch", 1: "sequence"}
   return OrderedDict(
       [
           ("""input_ids""", dynamic_axis),
           ("""attention_mask""", dynamic_axis),
       ]				)



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

import datasets


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


__lowerCamelCase				=			"""\
This metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.
It first canonicalizes the inputs (e.g., converting \"1/2\" to \"\\frac{1}{2}\") and then computes accuracy.
"""


__lowerCamelCase				=			R"""
Calculates accuracy after canonicalizing inputs.

Args:
    predictions: list of predictions to score. Each prediction
        is a string that contains natural language and LaTex.
    references: list of reference for each prediction. Each
        reference is a string that contains natural language
        and LaTex.
Returns:
    accuracy: accuracy after canonicalizing inputs
        (e.g., converting \"1/2\" to \"\\frac{1}{2}\")

Examples:
    >>> metric = datasets.load_metric(\"competition_math\")
    >>> results = metric.compute(references=[\"\\frac{1}{2}\"], predictions=[\"1/2\"])
    >>> print(results)
    {'accuracy': 1.0}
"""






@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION			,_KWARGS_DESCRIPTION					)
class     UpperCAmelCase						(		datasets.Metric					):



   def 							_SCREAMING_SNAKE_CASE  (self						:   Optional[int]					)						->      Optional[Any]:


          '''simple docstring'''


          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 							_SCREAMING_SNAKE_CASE  (self						:   Optional[int]       ,		snake_case__						:   str       ,		snake_case__						:   List[Any]					)						->      Optional[Any]:


          '''simple docstring'''


          snake_case			:  Optional[int]     							= 0.0
          for i, j in zip(snake_case__       ,		snake_case__					):
                 n_correct += 1.0 if math_equivalence.is_equiv(snake_case__       ,		snake_case__					) else 0.0
          snake_case			:  Optional[int]     							= n_correct / len(snake_case__					)
          return {
              "accuracy": accuracy,
          }





