



'''simple docstring'''




import functools
import operator

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


lowerCamelCase							:Optional[int]				    =					logging.get_logger(__name__)

lowerCamelCase							:Optional[int]				    =					{
    '''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 	_lowerCAmelCase							(			lowerCAmelCase_ ):
	__SCREAMING_SNAKE_CASE   :		Optional[int]					=					'wav2vec2'


	def __init__(self       ,      lowercase=32       ,      lowercase=768       ,      lowercase=12       ,      lowercase=12       ,      lowercase=3072       ,      lowercase="gelu"       ,      lowercase=0.1       ,      lowercase=0.1       ,      lowercase=0.1       ,      lowercase=0.0       ,      lowercase=0.0       ,      lowercase=0.1       ,      lowercase=0.1       ,      lowercase=0.02       ,      lowercase=1E-5       ,      lowercase="group"       ,      lowercase="gelu"       ,      lowercase=(512, 512, 512, 512, 512, 512, 512)       ,      lowercase=(5, 2, 2, 2, 2, 2, 2)       ,      lowercase=(10, 3, 3, 3, 3, 2, 2)       ,      lowercase=False       ,      lowercase=128       ,      lowercase=16       ,      lowercase=False       ,      lowercase=True       ,      lowercase=0.05       ,      lowercase=10       ,      lowercase=2       ,      lowercase=0.0       ,      lowercase=10       ,      lowercase=0       ,      lowercase=320       ,      lowercase=2       ,      lowercase=0.1       ,      lowercase=100       ,      lowercase=256       ,      lowercase=256       ,      lowercase=0.1       ,      lowercase="sum"       ,      lowercase=False       ,      lowercase=False       ,      lowercase=256       ,      lowercase=(512, 512, 512, 512, 1500)       ,      lowercase=(5, 3, 3, 1, 1)       ,      lowercase=(1, 2, 3, 1, 1)       ,      lowercase=512       ,      lowercase=0       ,      lowercase=1       ,      lowercase=2       ,      lowercase=False       ,      lowercase=3       ,      lowercase=2       ,      lowercase=3       ,      lowercase=None       ,      lowercase=None       ,      **lowercase       ,      ):
				super().__init__(**__lowerCAmelCase       ,      pad_token_id=__lowerCAmelCase       ,      bos_token_id=__lowerCAmelCase       ,      eos_token_id=__lowerCAmelCase							)
				A_	:						int	=     hidden_size
				A_	:						Union[str, Any]	=     feat_extract_norm
				A_	:						Optional[Any]	=     feat_extract_activation
				A_	:						int	=     list(__lowerCAmelCase							)
				A_	:						Union[str, Any]	=     list(__lowerCAmelCase							)
				A_	:						Optional[int]	=     list(__lowerCAmelCase							)
				A_	:						Any	=     conv_bias
				A_	:						str	=     num_conv_pos_embeddings
				A_	:						Dict	=     num_conv_pos_embedding_groups
				A_	:						Dict	=     len(self.conv_dim							)
				A_	:						Any	=     num_hidden_layers
				A_	:						Union[str, Any]	=     intermediate_size
				A_	:						Optional[Any]	=     hidden_act
				A_	:						Any	=     num_attention_heads
				A_	:						int	=     hidden_dropout
				A_	:						Union[str, Any]	=     attention_dropout
				A_	:						Any	=     activation_dropout
				A_	:						List[str]	=     feat_proj_dropout
				A_	:						Dict	=     final_dropout
				A_	:						Optional[Any]	=     layerdrop
				A_	:						int	=     layer_norm_eps
				A_	:						Tuple	=     initializer_range
				A_	:						Tuple	=     vocab_size
				A_	:						Tuple	=     do_stable_layer_norm
				A_	:						List[Any]	=     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
				A_	:						Dict	=     apply_spec_augment
				A_	:						List[Any]	=     mask_time_prob
				A_	:						Optional[int]	=     mask_time_length
				A_	:						int	=     mask_time_min_masks
				A_	:						Union[str, Any]	=     mask_feature_prob
				A_	:						Dict	=     mask_feature_length
				A_	:						int	=     mask_feature_min_masks

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

				# ctc loss
				A_	:						str	=     ctc_loss_reduction
				A_	:						int	=     ctc_zero_infinity

				# adapter
				A_	:						Optional[Any]	=     add_adapter
				A_	:						int	=     adapter_kernel_size
				A_	:						List[Any]	=     adapter_stride
				A_	:						Union[str, Any]	=     num_adapter_layers
				A_	:						Optional[int]	=     output_hidden_size or hidden_size
				A_	:						int	=     adapter_attn_dim

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

				# XVector-specific parameters. Feel free to ignore for other classes.
				A_	:						Optional[Any]	=     list(__lowerCAmelCase							)
				A_	:						str	=     list(__lowerCAmelCase							)
				A_	:						Tuple	=     list(__lowerCAmelCase							)
				A_	:						Tuple	=     xvector_output_dim


	@property
	def     _a	(self							):
				return functools.reduce(operator.mul       ,      self.conv_stride       ,      1							)
"""simple docstring"""


from sklearn.metrics import recall_score

import datasets


UpperCAmelCase__     						=  """
Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:
Recall = TP / (TP + FN)
Where TP is the true positives and FN is the false negatives.
"""


UpperCAmelCase__     						=  """
Args:
- **predictions** (`list` of `int`): The predicted labels.
- **references** (`list` of `int`): The ground truth labels.
- **labels** (`list` of `int`): The set of labels to include when `average` is not set to `binary`, and their order when average is `None`. Labels present in the data can be excluded in this input, for example to calculate a multiclass average ignoring a majority negative class, while labels not present in the data will result in 0 components in a macro average. For multilabel targets, labels are column indices. By default, all labels in y_true and y_pred are used in sorted order. Defaults to None.
- **pos_label** (`int`): The class label to use as the 'positive class' when calculating the recall. Defaults to `1`.
- **average** (`string`): This parameter is required for multiclass/multilabel targets. If None, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data. Defaults to `'binary'`.
    - `'binary'`: Only report results for the class specified by `pos_label`. This is applicable only if the target labels and predictions are binary.
    - `'micro'`: Calculate metrics globally by counting the total true positives, false negatives, and false positives.
    - `'macro'`: Calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account.
    - `'weighted'`: Calculate metrics for each label, and find their average weighted by support (the number of true instances for each label). This alters `'macro'` to account for label imbalance. Note that it can result in an F-score that is not between precision and recall.
    - `'samples'`: Calculate metrics for each instance, and find their average (only meaningful for multilabel classification).
- **sample_weight** (`list` of `float`): Sample weights Defaults to `None`.
- **zero_division** (): Sets the value to return when there is a zero division. Defaults to .
    - `'warn'`: If there is a zero division, the return value is `0`, but warnings are also raised.
    - `0`: If there is a zero division, the return value is `0`.
    - `1`: If there is a zero division, the return value is `1`.

Returns:
- **recall** (`float`, or `array` of `float`): Either the general recall score, or the recall scores for individual classes, depending on the values input to `labels` and `average`. Minimum possible value is 0. Maximum possible value is 1. A higher recall means that more of the positive examples have been labeled correctly. Therefore, a higher recall is generally considered better.

Examples:

    Example 1-A simple example with some errors
        >>> recall_metric = datasets.load_metric('recall')
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1])
        >>> print(results)
        {'recall': 0.6666666666666666}

    Example 2-The same example as Example 1, but with `pos_label=0` instead of the default `pos_label=1`.
        >>> recall_metric = datasets.load_metric('recall')
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1], pos_label=0)
        >>> print(results)
        {'recall': 0.5}

    Example 3-The same example as Example 1, but with `sample_weight` included.
        >>> recall_metric = datasets.load_metric('recall')
        >>> sample_weight = [0.9, 0.2, 0.9, 0.3, 0.8]
        >>> results = recall_metric.compute(references=[0, 0, 1, 1, 1], predictions=[0, 1, 0, 1, 1], sample_weight=sample_weight)
        >>> print(results)
        {'recall': 0.55}

    Example 4-A multiclass example, using different averages.
        >>> recall_metric = datasets.load_metric('recall')
        >>> predictions = [0, 2, 1, 0, 0, 1]
        >>> references = [0, 1, 2, 0, 1, 2]
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='macro')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='micro')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average='weighted')
        >>> print(results)
        {'recall': 0.3333333333333333}
        >>> results = recall_metric.compute(predictions=predictions, references=references, average=None)
        >>> print(results)
        {'recall': array([1., 0., 0.])}
"""


UpperCAmelCase__     						=  """
@article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P. and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.}, journal={Journal of Machine Learning Research}, volume={12}, pages={2825--2830}, year={2011}
"""


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


    def    lowerCAmelCase_     (    self		:     Tuple    ):
      return datasets.MetricInfo(
          description=_DESCRIPTION      , citation=_CITATION      , inputs_description=_KWARGS_DESCRIPTION      , features=datasets.Features(
              {
                  """predictions""": datasets.Sequence(datasets.Value("""int32"""    )    ),
                  """references""": datasets.Sequence(datasets.Value("""int32"""    )    ),
              }
              if self.config_name == """multilabel"""
              else {
                  """predictions""": datasets.Value("""int32"""    ),
                  """references""": datasets.Value("""int32"""    ),
              }    )      , reference_urls=["""https://scikit-learn.org/stable/modules/generated/sklearn.metrics.recall_score.html"""]      , )


    def    lowerCAmelCase_     (    self		:     List[Any]      , __lowerCAmelCase		:     int      , __lowerCAmelCase		:     Optional[Any]      , __lowerCAmelCase		:     int=None      , __lowerCAmelCase		:     Dict=1      , __lowerCAmelCase		:     List[str]="binary"      , __lowerCAmelCase		:     Any=None      , __lowerCAmelCase		:     int="warn"      , ):
      _UpperCAmelCase         =					recall_score(
          __lowerCAmelCase      , __lowerCAmelCase      , labels=__lowerCAmelCase      , pos_label=__lowerCAmelCase      , average=__lowerCAmelCase      , sample_weight=__lowerCAmelCase      , zero_division=__lowerCAmelCase      , )
      return {"recall": float(__lowerCAmelCase    ) if score.size == 1 else score}
