
'''simple docstring'''





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

import datasets


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


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


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

 '''simple docstring'''







 def 							UpperCamelCase  (					self		:  Union[str, 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 							UpperCamelCase  (					self		:  Tuple			,				snake_case__		:  Tuple			,				snake_case__		:  Dict ):



   '''simple docstring'''




   UpperCAmelCase__      :					List[Any]				       =							0.0
   for i, j in zip(_SCREAMING_SNAKE_CASE			,				_SCREAMING_SNAKE_CASE ):
     n_correct += 1.0 if math_equivalence.is_equiv(_SCREAMING_SNAKE_CASE			,				_SCREAMING_SNAKE_CASE ) else 0.0
   UpperCAmelCase__      :					str				       =							n_correct / len(_SCREAMING_SNAKE_CASE )
   return {
       "accuracy": accuracy,
   }









import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a							     =					logging.get_logger(__name__)

__a							     =					{
    'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}

class     __a(	_a  ):






    """simple docstring"""





    lowerCAmelCase         = '''wav2vec2'''





    def __init__( self  ,_SCREAMING_SNAKE_CASE=32  ,_SCREAMING_SNAKE_CASE=768  ,_SCREAMING_SNAKE_CASE=12  ,_SCREAMING_SNAKE_CASE=12  ,_SCREAMING_SNAKE_CASE=3_072  ,_SCREAMING_SNAKE_CASE="gelu"  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.02  ,_SCREAMING_SNAKE_CASE=1e-5  ,_SCREAMING_SNAKE_CASE="group"  ,_SCREAMING_SNAKE_CASE="gelu"  ,_SCREAMING_SNAKE_CASE=(512, 512, 512, 512, 512, 512, 512)  ,_SCREAMING_SNAKE_CASE=(5, 2, 2, 2, 2, 2, 2)  ,_SCREAMING_SNAKE_CASE=(10, 3, 3, 3, 3, 2, 2)  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=128  ,_SCREAMING_SNAKE_CASE=16  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=True  ,_SCREAMING_SNAKE_CASE=0.05  ,_SCREAMING_SNAKE_CASE=10  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=10  ,_SCREAMING_SNAKE_CASE=0  ,_SCREAMING_SNAKE_CASE=320  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=100  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE="sum"  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=(512, 512, 512, 512, 1_500)  ,_SCREAMING_SNAKE_CASE=(5, 3, 3, 1, 1)  ,_SCREAMING_SNAKE_CASE=(1, 2, 3, 1, 1)  ,_SCREAMING_SNAKE_CASE=512  ,_SCREAMING_SNAKE_CASE=0  ,_SCREAMING_SNAKE_CASE=1  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=3  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=3  ,_SCREAMING_SNAKE_CASE=None  ,_SCREAMING_SNAKE_CASE=None  ,**_SCREAMING_SNAKE_CASE  ,)					->						Optional[int]:
         super().__init__(**_SCREAMING_SNAKE_CASE  ,pad_token_id=_SCREAMING_SNAKE_CASE  ,bos_token_id=_SCREAMING_SNAKE_CASE  ,eos_token_id=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				int  =     hidden_size
         UpperCAmelCase_     :				Tuple  =     feat_extract_norm
         UpperCAmelCase_     :				List[Any]  =     feat_extract_activation
         UpperCAmelCase_     :				str  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Any  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Tuple  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Dict  =     conv_bias
         UpperCAmelCase_     :				str  =     num_conv_pos_embeddings
         UpperCAmelCase_     :				Any  =     num_conv_pos_embedding_groups
         UpperCAmelCase_     :				Tuple  =     len(self.conv_dim    )
         UpperCAmelCase_     :				Union[str, Any]  =     num_hidden_layers
         UpperCAmelCase_     :				Dict  =     intermediate_size
         UpperCAmelCase_     :				Any  =     hidden_act
         UpperCAmelCase_     :				Any  =     num_attention_heads
         UpperCAmelCase_     :				str  =     hidden_dropout
         UpperCAmelCase_     :				int  =     attention_dropout
         UpperCAmelCase_     :				Tuple  =     activation_dropout
         UpperCAmelCase_     :				List[str]  =     feat_proj_dropout
         UpperCAmelCase_     :				int  =     final_dropout
         UpperCAmelCase_     :				Union[str, Any]  =     layerdrop
         UpperCAmelCase_     :				Optional[Any]  =     layer_norm_eps
         UpperCAmelCase_     :				str  =     initializer_range
         UpperCAmelCase_     :				List[str]  =     vocab_size
         UpperCAmelCase_     :				Optional[int]  =     do_stable_layer_norm
         UpperCAmelCase_     :				Optional[int]  =     use_weighted_layer_sum

         if (
             (len(self.conv_stride    ) != self.num_feat_extract_layers)
             or (len(self.conv_kernel    ) != self.num_feat_extract_layers)
             or (len(self.conv_dim    ) != self.num_feat_extract_layers)
         ):
              raise ValueError(
                  '''Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='''
                  ''' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='''
                  f''' {len(self.conv_dim    )}`, `len(config.conv_stride) = {len(self.conv_stride    )}`,'''
                  f''' `len(config.conv_kernel) = {len(self.conv_kernel    )}`.'''    )

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         UpperCAmelCase_     :				Optional[int]  =     apply_spec_augment
         UpperCAmelCase_     :				Tuple  =     mask_time_prob
         UpperCAmelCase_     :				Optional[Any]  =     mask_time_length
         UpperCAmelCase_     :				Union[str, Any]  =     mask_time_min_masks
         UpperCAmelCase_     :				Optional[Any]  =     mask_feature_prob
         UpperCAmelCase_     :				str  =     mask_feature_length
         UpperCAmelCase_     :				Dict  =     mask_feature_min_masks

         # parameters for pretraining with codevector quantized representations
         UpperCAmelCase_     :				Union[str, Any]  =     num_codevectors_per_group
         UpperCAmelCase_     :				Any  =     num_codevector_groups
         UpperCAmelCase_     :				Union[str, Any]  =     contrastive_logits_temperature
         UpperCAmelCase_     :				List[str]  =     feat_quantizer_dropout
         UpperCAmelCase_     :				Dict  =     num_negatives
         UpperCAmelCase_     :				List[str]  =     codevector_dim
         UpperCAmelCase_     :				List[str]  =     proj_codevector_dim
         UpperCAmelCase_     :				str  =     diversity_loss_weight

         # ctc loss
         UpperCAmelCase_     :				List[Any]  =     ctc_loss_reduction
         UpperCAmelCase_     :				List[str]  =     ctc_zero_infinity

         # adapter
         UpperCAmelCase_     :				Optional[Any]  =     add_adapter
         UpperCAmelCase_     :				Any  =     adapter_kernel_size
         UpperCAmelCase_     :				Optional[int]  =     adapter_stride
         UpperCAmelCase_     :				List[Any]  =     num_adapter_layers
         UpperCAmelCase_     :				Optional[Any]  =     output_hidden_size or hidden_size
         UpperCAmelCase_     :				Optional[int]  =     adapter_attn_dim

         # SequenceClassification-specific parameter. Feel free to ignore for other classes.
         UpperCAmelCase_     :				List[str]  =     classifier_proj_size

         # XVector-specific parameters. Feel free to ignore for other classes.
         UpperCAmelCase_     :				List[str]  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				int  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Dict  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Any  =     xvector_output_dim





    @property
    def 				a__ ( self    )					->						Any:
         return functools.reduce(operator.mul  ,self.conv_stride  ,1    )