





import functools
import operator

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


lowercase_					     =	logging.get_logger(__name__)

lowercase_					     =	{
    """asapp/sew-d-tiny-100k""": """https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json""",
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}
class        SCREAMING_SNAKE_CASE     (UpperCAmelCase   ):
   _UpperCamelCase					:	Union[str, Any]				      = 'sew-d'


   def __init__(					self    :       Any    ,  a    :       str=32    ,  a    :       Optional[int]=768    ,  a    :       List[str]=12    ,  a    :       Optional[int]=12    ,  a    :       Tuple=3_072    ,  a    :       Optional[Any]=2    ,  a    :       Any=512    ,  a    :       List[str]=256    ,  a    :       int=True    ,  a    :       int=True    ,  a    :       List[Any]=("p2c", "c2p")    ,  a    :       Any="layer_norm"    ,  a    :       str="gelu_python"    ,  a    :       Optional[Any]=0.1    ,  a    :       str=0.1    ,  a    :       Any=0.1    ,  a    :       Tuple=0.0    ,  a    :       List[Any]=0.1    ,  a    :       List[str]=0.02    ,  a    :       Optional[Any]=1E-7    ,  a    :       List[Any]=1E-5    ,  a    :       Optional[int]="group"    ,  a    :       Tuple="gelu"    ,  a    :       List[str]=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)    ,  a    :       Any=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)    ,  a    :       str=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)    ,  a    :       List[Any]=False    ,  a    :       Optional[int]=128    ,  a    :       Tuple=16    ,  a    :       Tuple=True    ,  a    :       Optional[Any]=0.05    ,  a    :       List[Any]=10    ,  a    :       Dict=2    ,  a    :       Optional[Any]=0.0    ,  a    :       Optional[Any]=10    ,  a    :       Any=0    ,  a    :       Union[str, Any]="mean"    ,  a    :       List[str]=False    ,  a    :       str=False    ,  a    :       Union[str, Any]=256    ,  a    :       int=0    ,  a    :       Optional[Any]=1    ,  a    :       Tuple=2    ,  **a    :       List[Any]    ,  )->     Optional[Any]:





     """simple docstring"""







     super().__init__(**a    ,  pad_token_id=a    ,  bos_token_id=a    ,  eos_token_id=a )
     lowercase__			    =						hidden_size
     lowercase__			    =						feat_extract_norm
     lowercase__			    =						feat_extract_activation
     lowercase__			    =						list(a )
     lowercase__			    =						list(a )
     lowercase__			    =						list(a )
     lowercase__			    =						conv_bias
     lowercase__			    =						num_conv_pos_embeddings
     lowercase__			    =						num_conv_pos_embedding_groups
     lowercase__			    =						len(self.conv_dim )
     lowercase__			    =						num_hidden_layers
     lowercase__			    =						intermediate_size
     lowercase__			    =						squeeze_factor
     lowercase__			    =						max_position_embeddings
     lowercase__			    =						position_buckets
     lowercase__			    =						share_att_key
     lowercase__			    =						relative_attention
     lowercase__			    =						norm_rel_ebd
     lowercase__			    =						list(a )
     lowercase__			    =						hidden_act
     lowercase__			    =						num_attention_heads
     lowercase__			    =						hidden_dropout
     lowercase__			    =						attention_dropout
     lowercase__			    =						activation_dropout
     lowercase__			    =						feat_proj_dropout
     lowercase__			    =						final_dropout
     lowercase__			    =						layer_norm_eps
     lowercase__			    =						feature_layer_norm_eps
     lowercase__			    =						initializer_range
     lowercase__			    =						vocab_size

     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)`,'
           f"""but is `len(config.conv_dim) = {len(self.conv_dim )}`, `len(config.conv_stride)"""
           f"""= {len(self.conv_stride )}`, `len(config.conv_kernel) = {len(self.conv_kernel )}`.""" )

     # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
     lowercase__			    =						apply_spec_augment
     lowercase__			    =						mask_time_prob
     lowercase__			    =						mask_time_length
     lowercase__			    =						mask_time_min_masks
     lowercase__			    =						mask_feature_prob
     lowercase__			    =						mask_feature_length
     lowercase__			    =						mask_feature_min_masks

     # ctc loss
     lowercase__			    =						ctc_loss_reduction
     lowercase__			    =						ctc_zero_infinity

     # sequence classification
     lowercase__			    =						use_weighted_layer_sum
     lowercase__			    =						classifier_proj_size


   @property
   def  SCREAMING_SNAKE_CASE_							(					self    :       Optional[Any] )->     List[Any]:





     """simple docstring"""







     return functools.reduce(operator.mul    ,  self.conv_stride    ,  1 )









from scipy.stats import spearmanr

import datasets


lowercase_					     =	"""
The Spearman rank-order correlation coefficient is a measure of the
relationship between two datasets. Like other correlation coefficients,
this one varies between -1 and +1 with 0 implying no correlation.
Positive correlations imply that as data in dataset x increases, so
does data in dataset y. Negative correlations imply that as x increases,
y decreases. Correlations of -1 or +1 imply an exact monotonic relationship.

Unlike the Pearson correlation, the Spearman correlation does not
assume that both datasets are normally distributed.

The p-value roughly indicates the probability of an uncorrelated system
producing datasets that have a Spearman correlation at least as extreme
as the one computed from these datasets. The p-values are not entirely
reliable but are probably reasonable for datasets larger than 500 or so.
"""

lowercase_					     =	"""
Args:
    predictions (`List[float]`): Predicted labels, as returned by a model.
    references (`List[float]`): Ground truth labels.
    return_pvalue (`bool`): If `True`, returns the p-value. If `False`, returns
            only the spearmanr score. Defaults to `False`.
Returns:
    spearmanr (`float`): Spearman correlation coefficient.
    p-value (`float`): p-value. **Note**: is only returned if `return_pvalue=True` is input.
Examples:
    Example 1:
        >>> spearmanr_metric = datasets.load_metric(\"spearmanr\")
        >>> results = spearmanr_metric.compute(references=[1, 2, 3, 4, 5], predictions=[10, 9, 2.5, 6, 4])
        >>> print(results)
        {'spearmanr': -0.7}

    Example 2:
        >>> spearmanr_metric = datasets.load_metric(\"spearmanr\")
        >>> results = spearmanr_metric.compute(references=[1, 2, 3, 4, 5],
        ...                                     predictions=[10, 9, 2.5, 6, 4],
        ...                                     return_pvalue=True)
        >>> print(results['spearmanr'])
        -0.7
        >>> print(round(results['spearmanr_pvalue'], 2))
        0.19
"""

lowercase_					     =	R"""\
@book{kokoska2000crc,
  title={CRC standard probability and statistics tables and formulae},
  author={Kokoska, Stephen and Zwillinger, Daniel},
  year={2000},
  publisher={Crc Press}
}
@article{2020SciPy-NMeth,
  author  = {Virtanen, Pauli and Gommers, Ralf and Oliphant, Travis E. and
            Haberland, Matt and Reddy, Tyler and Cournapeau, David and
            Burovski, Evgeni and Peterson, Pearu and Weckesser, Warren and
            Bright, Jonathan and {van der Walt}, St{\'e}fan J. and
            Brett, Matthew and Wilson, Joshua and Millman, K. Jarrod and
            Mayorov, Nikolay and Nelson, Andrew R. J. and Jones, Eric and
            Kern, Robert and Larson, Eric and Carey, C J and
            Polat, {\.I}lhan and Feng, Yu and Moore, Eric W. and
            {VanderPlas}, Jake and Laxalde, Denis and Perktold, Josef and
            Cimrman, Robert and Henriksen, Ian and Quintero, E. A. and
            Harris, Charles R. and Archibald, Anne M. and
            Ribeiro, Ant{\^o}nio H. and Pedregosa, Fabian and
            {van Mulbregt}, Paul and {SciPy 1.0 Contributors}},
  title   = {{{SciPy} 1.0: Fundamental Algorithms for Scientific
            Computing in Python}},
  journal = {Nature Methods},
  year    = {2020},
  volume  = {17},
  pages   = {261--272},
  adsurl  = {https://rdcu.be/b08Wh},
  doi     = {10.1038/s41592-019-0686-2},
}
"""
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION    ,			_KWARGS_DESCRIPTION   )
class        SCREAMING_SNAKE_CASE     (datasets.Metric   ):


   def  SCREAMING_SNAKE_CASE_							(					self    :       Union[str, Any] )->     Tuple:





     """simple docstring"""







     return datasets.MetricInfo(
         description=_DESCRIPTION    ,  citation=_CITATION    ,  inputs_description=_KWARGS_DESCRIPTION    ,  features=datasets.Features(
             {
                 'predictions': datasets.Value('float' ),
                 'references': datasets.Value('float' ),
             } )    ,  reference_urls=['https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html']    ,  )


   def  SCREAMING_SNAKE_CASE_							(					self    :       int    ,  a    :       str    ,  a    :       Any    ,  a    :       str=False )->     Optional[int]:





     """simple docstring"""







     lowercase__			    =						spearmanr(a    ,  a )
     if return_pvalue:
       return {"spearmanr": results[0], "spearmanr_pvalue": results[1]}
     else:
       return {"spearmanr": results[0]}


