

'''simple docstring'''




from sklearn.metrics import precision_score

import datasets


_a				: Union[str, Any] 							=						'\nPrecision is the fraction of correctly labeled positive examples out of all of the examples that were labeled as positive. It is computed via the equation:\nPrecision = TP / (TP + FP)\nwhere TP is the True positives (i.e. the examples correctly labeled as positive) and FP is the False positive examples (i.e. the examples incorrectly labeled as positive).\n'


_a				: Tuple 							=						'\nArgs:\n    predictions (`list` of `int`): Predicted class labels.\n    references (`list` of `int`): Actual class labels.\n    labels (`list` of `int`): The set of labels to include when `average` is not set to `\'binary\'`. If `average` is `None`, it should be the label order. Labels present in the data can be excluded, for example to calculate a multiclass average ignoring a majority negative class. 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 `predictions` and `references` are used in sorted order. Defaults to None.\n    pos_label (`int`): The class to be considered the positive class, in the case where `average` is set to `binary`. Defaults to 1.\n    average (`string`): This parameter is required for multiclass/multilabel targets. If set to `None`, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data. Defaults to `\'binary\'`.\n\n        - \'binary\': Only report results for the class specified by `pos_label`. This is applicable only if the classes found in `predictions` and `references` are binary.\n        - \'micro\': Calculate metrics globally by counting the total true positives, false negatives and false positives.\n        - \'macro\': Calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account.\n        - \'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. This option can result in an F-score that is not between precision and recall.\n        - \'samples\': Calculate metrics for each instance, and find their average (only meaningful for multilabel classification).\n    sample_weight (`list` of `float`): Sample weights Defaults to None.\n    zero_division (`int` or `string`): Sets the value to return when there is a zero division. Defaults to \'warn\'.\n\n        - 0: Returns 0 when there is a zero division.\n        - 1: Returns 1 when there is a zero division.\n        - \'warn\': Raises warnings and then returns 0 when there is a zero division.\n\nReturns:\n    precision (`float` or `array` of `float`): Precision score or list of precision scores, depending on the value passed to `average`. Minimum possible value is 0. Maximum possible value is 1. Higher values indicate that fewer negative examples were incorrectly labeled as positive, which means that, generally, higher scores are better.\n\nExamples:\n\n    Example 1-A simple binary example\n        >>> precision_metric = datasets.load_metric("precision")\n        >>> results = precision_metric.compute(references=[0, 1, 0, 1, 0], predictions=[0, 0, 1, 1, 0])\n        >>> print(results)\n        {\'precision\': 0.5}\n\n    Example 2-The same simple binary example as in Example 1, but with `pos_label` set to `0`.\n        >>> precision_metric = datasets.load_metric("precision")\n        >>> results = precision_metric.compute(references=[0, 1, 0, 1, 0], predictions=[0, 0, 1, 1, 0], pos_label=0)\n        >>> print(round(results[\'precision\'], 2))\n        0.67\n\n    Example 3-The same simple binary example as in Example 1, but with `sample_weight` included.\n        >>> precision_metric = datasets.load_metric("precision")\n        >>> results = precision_metric.compute(references=[0, 1, 0, 1, 0], predictions=[0, 0, 1, 1, 0], sample_weight=[0.9, 0.5, 3.9, 1.2, 0.3])\n        >>> print(results)\n        {\'precision\': 0.23529411764705882}\n\n    Example 4-A multiclass example, with different values for the `average` input.\n        >>> predictions = [0, 2, 1, 0, 0, 1]\n        >>> references = [0, 1, 2, 0, 1, 2]\n        >>> results = precision_metric.compute(predictions=predictions, references=references, average=\'macro\')\n        >>> print(results)\n        {\'precision\': 0.2222222222222222}\n        >>> results = precision_metric.compute(predictions=predictions, references=references, average=\'micro\')\n        >>> print(results)\n        {\'precision\': 0.3333333333333333}\n        >>> results = precision_metric.compute(predictions=predictions, references=references, average=\'weighted\')\n        >>> print(results)\n        {\'precision\': 0.2222222222222222}\n        >>> results = precision_metric.compute(predictions=predictions, references=references, average=None)\n        >>> print([round(res, 2) for res in results[\'precision\']])\n        [0.67, 0.0, 0.0]\n'


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



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

  '''simple docstring'''





  def 						snake_case_			(     self     )							->				Any:


    """simple docstring"""
    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.precision_score.html']   , )





  def 						snake_case_			(     self   , a_   , a_   , a_=None   , a_=1   , a_="binary"   , a_=None   , a_="warn"   , )							->				Optional[Any]:


    """simple docstring"""
    UpperCAmelCase													=	precision_score(
        a_   , a_   , labels=a_   , pos_label=a_   , average=a_   , sample_weight=a_   , zero_division=a_   , )
    return {"precision": float(a_     ) if score.size == 1 else score}






'''simple docstring'''




from collections import OrderedDict
from typing import Mapping

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


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

_a				: Dict 							=						{
    'mnaylor/mega-base-wikitext': 'https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json',
}



class        lowercase_	(		a ):

  '''simple docstring'''





  __lowerCAmelCase					: List[str]      =   "mega"
  def __init__(     self   , a_=3_0_5_2_2   , a_=1_2_8   , a_=4   , a_=2_5_6   , a_=1_6   , a_=True   , a_=6_4   , a_=False   , a_=-1   , a_=None   , a_=True   , a_="scalenorm"   , a_=True   , a_="silu"   , a_="softmax"   , a_=0.1   , a_=0.1   , a_=0.1   , a_=False   , a_=True   , a_=2_5_6   , a_=True   , a_=0.1   , a_=2_0_4_8   , a_=False   , a_=2   , a_=0.02   , a_=0.2   , a_=0.02   , a_=1.0   , a_=1   , a_=0   , a_=2   , a_="rotary"   , a_=None   , a_=True   , a_=True   , **a_   , )							->				Any:


    """simple docstring"""
    super().__init__(pad_token_id=a_   , bos_token_id=a_   , eos_token_id=a_   , **a_     )

    UpperCAmelCase													=	vocab_size
    UpperCAmelCase													=	hidden_size
    UpperCAmelCase													=	num_hidden_layers
    UpperCAmelCase													=	activation
    UpperCAmelCase													=	attention_activation
    UpperCAmelCase													=	intermediate_size
    UpperCAmelCase													=	ema_projection_size
    UpperCAmelCase													=	bidirectional
    UpperCAmelCase													=	shared_representation_size
    UpperCAmelCase													=	use_chunking
    UpperCAmelCase													=	chunk_size
    UpperCAmelCase													=	truncation
    UpperCAmelCase													=	normalize_before_mega
    UpperCAmelCase													=	normalization_type
    UpperCAmelCase													=	norm_affine
    UpperCAmelCase													=	dropout_prob
    UpperCAmelCase													=	hidden_dropout_prob
    UpperCAmelCase													=	attention_probs_dropout_prob
    UpperCAmelCase													=	use_feature_dropout
    UpperCAmelCase													=	use_normalized_ffn
    UpperCAmelCase													=	nffn_hidden_size
    UpperCAmelCase													=	normalize_before_ffn
    UpperCAmelCase													=	nffn_activation_dropout_prob
    UpperCAmelCase													=	max_positions
    UpperCAmelCase													=	add_token_type_embeddings
    UpperCAmelCase													=	type_vocab_size
    UpperCAmelCase													=	initializer_range
    UpperCAmelCase													=	ema_delta_alpha_range
    UpperCAmelCase													=	ema_beta_range
    UpperCAmelCase													=	ema_gamma_omega_range
    UpperCAmelCase													=	relative_positional_bias
    UpperCAmelCase													=	use_cache
    UpperCAmelCase													=	classifier_dropout
    UpperCAmelCase													=	add_lm_hidden_dense_layer
    UpperCAmelCase													=	1  # not used but required by Hugging Face




class        lowercase_	(		a ):

  '''simple docstring'''





  @property
  def 						snake_case_			(     self     )							->				Mapping[str, Mapping[int, str]]:


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


