
"""simple docstring"""




import unittest
from unittest.util import safe_repr

from transformers import AutoTokenizer, RwkvConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        RWKV_PRETRAINED_MODEL_ARCHIVE_LIST,
        RwkvForCausalLM,
        RwkvModel,
    )
    from transformers.pytorch_utils import is_torch_greater_or_equal_than_2_0
else:
    a		:					Any    	=					False







class 						lowercase:



     def __init__(       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE=1_4    ,							__SCREAMING_SNAKE_CASE=7    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=9_9    ,							__SCREAMING_SNAKE_CASE=3_2    ,							__SCREAMING_SNAKE_CASE=5    ,							__SCREAMING_SNAKE_CASE=3_7    ,							__SCREAMING_SNAKE_CASE="gelu"    ,							__SCREAMING_SNAKE_CASE=0.1    ,							__SCREAMING_SNAKE_CASE=0.1    ,							__SCREAMING_SNAKE_CASE=5_1_2    ,							__SCREAMING_SNAKE_CASE=1_6    ,							__SCREAMING_SNAKE_CASE=2    ,							__SCREAMING_SNAKE_CASE=3    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=None    ,							)		->    int:







         """simple docstring"""



         a__    = parent
         a__    = batch_size
         a__    = seq_length
         a__    = is_training
         a__    = use_token_type_ids
         a__    = use_input_mask
         a__    = use_labels
         a__    = use_mc_token_ids
         a__    = vocab_size
         a__    = hidden_size
         a__    = num_hidden_layers
         a__    = intermediate_size
         a__    = hidden_act
         a__    = hidden_dropout_prob
         a__    = attention_probs_dropout_prob
         a__    = max_position_embeddings
         a__    = type_vocab_size
         a__    = type_sequence_label_size
         a__    = num_labels
         a__    = num_choices
         a__    = scope
         a__    = vocab_size - 1
         a__    = vocab_size - 1
         a__    = vocab_size - 1



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







         """simple docstring"""



         return RwkvConfig.from_pretrained('sgugger/rwkv-4-pile-7b'      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=False      )		->    int:







         """simple docstring"""



         a__    = ids_tensor([self.batch_size, self.seq_length]    ,							self.vocab_size      )

         a__    = None
         if self.use_input_mask:
             a__    = random_attention_mask([self.batch_size, self.seq_length]      )

         a__    = None
         if self.use_token_type_ids:
             a__    = ids_tensor([self.batch_size, self.seq_length]    ,							self.type_vocab_size      )

         a__    = None
         if self.use_mc_token_ids:
             a__    = ids_tensor([self.batch_size, self.num_choices]    ,							self.seq_length      )

         a__    = None
         a__    = None
         a__    = None
         if self.use_labels:
             a__    = ids_tensor([self.batch_size]    ,							self.type_sequence_label_size      )
             a__    = ids_tensor([self.batch_size, self.seq_length]    ,							self.num_labels      )
             a__    = ids_tensor([self.batch_size]    ,							self.num_choices      )

         a__    = self.get_config(
             gradient_checkpointing=__SCREAMING_SNAKE_CASE    ,							scale_attn_by_inverse_layer_idx=__SCREAMING_SNAKE_CASE    ,							reorder_and_upcast_attn=__SCREAMING_SNAKE_CASE    ,							)

         return (
             config,
             input_ids,
             input_mask,
             None,
             token_type_ids,
             mc_token_ids,
             sequence_labels,
             token_labels,
             choice_labels,
         )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=False      )		->    str:







         """simple docstring"""



         return RwkvConfig(
             vocab_size=self.vocab_size    ,							hidden_size=self.hidden_size    ,							num_hidden_layers=self.num_hidden_layers    ,							intermediate_size=self.intermediate_size    ,							activation_function=self.hidden_act    ,							resid_pdrop=self.hidden_dropout_prob    ,							attn_pdrop=self.attention_probs_dropout_prob    ,							n_positions=self.max_position_embeddings    ,							type_vocab_size=self.type_vocab_size    ,							use_cache=__SCREAMING_SNAKE_CASE    ,							bos_token_id=self.bos_token_id    ,							eos_token_id=self.eos_token_id    ,							pad_token_id=self.pad_token_id    ,							gradient_checkpointing=__SCREAMING_SNAKE_CASE    ,							scale_attn_by_inverse_layer_idx=__SCREAMING_SNAKE_CASE    ,							reorder_and_upcast_attn=__SCREAMING_SNAKE_CASE    ,							)



     def  lowercase__     (       self      )		->    List[Any]:







         """simple docstring"""



         a__    = self.get_config()
         a__    = 3_0_0
         return config



     def  lowercase__     (       self      )		->    List[Any]:







         """simple docstring"""



         (
             (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    
         )    = self.prepare_config_and_inputs()

         a__    = floats_tensor([self.batch_size, self.seq_length, self.hidden_size]      )
         a__    = ids_tensor([self.batch_size, self.seq_length]    ,							vocab_size=2      )

         return (
             config,
             input_ids,
             input_mask,
             head_mask,
             token_type_ids,
             sequence_labels,
             token_labels,
             choice_labels,
             encoder_hidden_states,
             encoder_attention_mask,
         )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							*__SCREAMING_SNAKE_CASE      )		->    Optional[int]:







         """simple docstring"""



         a__    = True
         a__    = RwkvModel(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()

         a__    = model(__SCREAMING_SNAKE_CASE      )

         self.parent.assertEqual(result.last_hidden_state.shape    ,							(self.batch_size, self.seq_length, self.hidden_size)      )
         self.parent.assertEqual(len(result.hidden_states      )    ,							config.num_hidden_layers + 1      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							*__SCREAMING_SNAKE_CASE      )		->    Optional[Any]:







         """simple docstring"""



         a__    = RwkvForCausalLM(__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()

         a__    = model(__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.loss.shape    ,							()      )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.seq_length, self.vocab_size)      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							*__SCREAMING_SNAKE_CASE      )		->    str:







         """simple docstring"""



         a__    = RwkvModel(config=__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         model.eval()

         a__    = model(__SCREAMING_SNAKE_CASE      )
         a__    = outputs.last_hidden_state

         a__    = model(input_ids[:, :2]      )
         a__    = outputs.last_hidden_state

         # Using the state computed on the first inputs, we will get the same output
         a__    = model(input_ids[:, 2:]    ,							state=outputs.state      )
         a__    = outputs.last_hidden_state

         self.parent.assertTrue(torch.allclose(torch.cat([output_one, output_two]    ,							dim=1      )    ,							__SCREAMING_SNAKE_CASE    ,							atol=1e-5      )      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							*__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE=False      )		->    int:







         """simple docstring"""



         a__    = RwkvForCausalLM(__SCREAMING_SNAKE_CASE      )
         model.to(__SCREAMING_SNAKE_CASE      )
         if gradient_checkpointing:
             model.gradient_checkpointing_enable()

         a__    = model(__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE      )
         self.parent.assertEqual(result.loss.shape    ,							()      )
         self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.seq_length, self.vocab_size)      )
         result.loss.backward()




     def  lowercase__     (       self      )		->    Optional[int]:







         """simple docstring"""



         a__    = self.prepare_config_and_inputs()

         (
             (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    (
             a__
         )  ,    
         )    = config_and_inputs

         a__    = {'input_ids': input_ids}

         return config, inputs_dict







@unittest.skipIf(
    not is_torch_greater_or_equal_than_2_0						,	reason='See https://github.com/huggingface/transformers/pull/24204'					)
@require_torch
class 						lowercase(_lowercase						,	_lowercase						,	_lowercase						,	unittest.TestCase					):
     __snake_case:  List[str]  				=    (RwkvModel, RwkvForCausalLM) if is_torch_available() else ()
     __snake_case:  Any  				=    (
         {'feature-extraction': RwkvModel, 'text-generation': RwkvForCausalLM} if is_torch_available() else {}
     )
     # all_generative_model_classes = (RwkvForCausalLM,) if is_torch_available() else ()
     __snake_case:  List[Any]  				=    False
     __snake_case:  Union[str, Any]  				=    False
     __snake_case:  List[str]  				=    False
     __snake_case:  Optional[Any]  				=    False
     __snake_case:  Optional[int]  				=    False  # Rwkv does not support head masking



     def  lowercase__     (       self      )		->    Optional[Any]:







         """simple docstring"""



         a__    = RwkvModelTester(self      )
         a__    = ConfigTester(
             self    ,							config_class=__SCREAMING_SNAKE_CASE    ,							n_embd=3_7    ,							common_properties=['hidden_size', 'num_hidden_layers']      )



     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE=None      )		->    List[Any]:







         """simple docstring"""



         if isinstance(__SCREAMING_SNAKE_CASE    ,							torch.Tensor      ):
             a__  ,    a__    = member.max().item(), member.min().item()
         elif isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      ) or isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      ):
             a__  ,    a__    = max(__SCREAMING_SNAKE_CASE      ), min(__SCREAMING_SNAKE_CASE      )

         if not isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      ):
             raise TypeError('container should be a list or tuple'      )
         elif len(__SCREAMING_SNAKE_CASE      ) != 2:
             raise ValueError('container should have 2 elements'      )

         a__  ,    a__    = container

         a__    = (min_value >= expected_min) and (max_value <= expected_max)

         if not is_inside_interval:
             a__    = '%s not found in %s' % (safe_repr(__SCREAMING_SNAKE_CASE      ), safe_repr(__SCREAMING_SNAKE_CASE      ))
             self.fail(self._formatMessage(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )      )



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         self.config_tester.run_common_tests()



     def  lowercase__     (       self      )		->    List[Any]:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_rwkv_model(*__SCREAMING_SNAKE_CASE      )



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







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_causl_lm(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    List[Any]:







         """simple docstring"""



         a__    = self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_state_equivalency(*__SCREAMING_SNAKE_CASE      )



     def  lowercase__     (       self      )		->    Optional[int]:







         """simple docstring"""



         a__  ,    a__    = self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
             a__    = model_class(config=__SCREAMING_SNAKE_CASE      )
             for name, param in model.named_parameters():
                 if "time_decay" in name:
                     if param.requires_grad:
                         self.assertTrue(param.data.max().item() == 3.0      )
                         self.assertTrue(param.data.min().item() == -5.0      )
                 elif "time_first" in name:
                     if param.requires_grad:
                         # check if it's a ones like
                         self.assertTrue(torch.allclose(param.data    ,							torch.ones_like(param.data      )    ,							atol=1e-5    ,							rtol=1e-5      )      )
                 elif any(x in name for x in ['time_mix_key', 'time_mix_receptance']      ):
                     if param.requires_grad:
                         self.assertInterval(
                             param.data    ,							[0.0, 1.0]    ,							msg=f'Parameter {name} of model {model_class} seems not properly initialized'    ,							)
                 elif "time_mix_value" in name:
                     if param.requires_grad:
                         self.assertInterval(
                             param.data    ,							[0.0, 1.3]    ,							msg=f'Parameter {name} of model {model_class} seems not properly initialized'    ,							)



     def  lowercase__     (       self      )		->    str:







         """simple docstring"""



         a__  ,    a__    = self.model_tester.prepare_config_and_inputs_for_common()
         a__    = True

         a__    = getattr(self.model_tester    ,							'seq_length'    ,							__SCREAMING_SNAKE_CASE      )

         for model_class in self.all_model_classes:
             a__    = True
             a__    = False
             a__    = True
             a__    = model_class(__SCREAMING_SNAKE_CASE      )
             model.to(__SCREAMING_SNAKE_CASE      )
             model.eval()

             a__    = self._prepare_for_class(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )
             a__    = inputs['input_ids'].shape[0]
             with torch.no_grad():
                 a__    = model(**__SCREAMING_SNAKE_CASE      )
             a__    = outputs.attentions
             self.assertEqual(len(__SCREAMING_SNAKE_CASE      )    ,							self.model_tester.num_hidden_layers      )

             # check that output_attentions also work using config
             del inputs_dict["output_attentions"]
             a__    = True
             a__    = model_class(__SCREAMING_SNAKE_CASE      )
             model.to(__SCREAMING_SNAKE_CASE      )
             model.eval()

             a__    = self._prepare_for_class(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )
             a__    = inputs['input_ids'].shape[0]
             with torch.no_grad():
                 a__    = model(**__SCREAMING_SNAKE_CASE      )
             a__    = outputs.attentions
             self.assertEqual(len(__SCREAMING_SNAKE_CASE      )    ,							self.model_tester.num_hidden_layers      )

             self.assertListEqual(
                 list(attentions[0].shape[-3:]      )    ,							[batch_size, seq_len, config.hidden_size]    ,							)
             a__    = len(__SCREAMING_SNAKE_CASE      )

             # Check attention is always last and order is fine
             a__    = True
             a__    = True
             a__    = model_class(__SCREAMING_SNAKE_CASE      )
             model.to(__SCREAMING_SNAKE_CASE      )
             model.eval()

             a__    = self._prepare_for_class(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )
             a__    = inputs['input_ids'].shape[0]
             with torch.no_grad():
                 a__    = model(**__SCREAMING_SNAKE_CASE      )

             a__    = 1
             self.assertEqual(out_len + added_hidden_states    ,							len(__SCREAMING_SNAKE_CASE      )      )

             a__    = outputs.attentions

             self.assertEqual(len(__SCREAMING_SNAKE_CASE      )    ,							self.model_tester.num_hidden_layers      )
             self.assertListEqual(
                 list(self_attentions[0].shape[-3:]      )    ,							[batch_size, seq_len, config.hidden_size]    ,							)




     @slow
     def  lowercase__     (       self      )		->    Dict:







         """simple docstring"""



         for model_name in RWKV_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             a__    = RwkvModel.from_pretrained(__SCREAMING_SNAKE_CASE      )
             self.assertIsNotNone(__SCREAMING_SNAKE_CASE      )







@unittest.skipIf(
    not is_torch_greater_or_equal_than_2_0						,	reason='See https://github.com/huggingface/transformers/pull/24204'					)
@slow
class 						lowercase(unittest.TestCase					):



     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         a__    = 'RWKV/rwkv-4-169m-pile'
         a__    = AutoTokenizer.from_pretrained(self.model_id      )



     def  lowercase__     (       self      )		->    Dict:







         """simple docstring"""



         a__    = 'Hello my name is Jasmine and I am a newbie to the'
         a__    = RwkvForCausalLM.from_pretrained(self.model_id      ).to(__SCREAMING_SNAKE_CASE      )

         a__    = self.tokenizer('Hello my name is'    ,							return_tensors='pt'      ).input_ids.to(__SCREAMING_SNAKE_CASE      )
         a__    = model.generate(__SCREAMING_SNAKE_CASE    ,							max_new_tokens=1_0      )
         a__    = self.tokenizer.decode(output[0].tolist()      )

         self.assertEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )




     def  lowercase__     (       self      )		->    int:







         """simple docstring"""



         a__    = 'Hello my name is Jasmine and I am a newbie to the'

         a__    = self.tokenizer('Hello my name is'    ,							return_tensors='pt'      ).input_ids.to(__SCREAMING_SNAKE_CASE      )
         a__    = RwkvForCausalLM.from_pretrained(self.model_id    ,							torch_dtype=torch.bfloataa      ).to(__SCREAMING_SNAKE_CASE      )

         a__    = model.generate(__SCREAMING_SNAKE_CASE    ,							max_new_tokens=1_0      )
         a__    = self.tokenizer.decode(output[0].tolist()      )

         self.assertEqual(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE      )




"""simple docstring"""




from sklearn.metrics import roc_auc_score

import datasets


a		:					Tuple    	=					'\nThis metric computes the area under the curve (AUC) for the Receiver Operating Characteristic Curve (ROC). The return values represent how well the model used is predicting the correct classes, based on the input data. A score of `0.5` means that the model is predicting exactly at chance, i.e. the model\'s predictions are correct at the same rate as if the predictions were being decided by the flip of a fair coin or the roll of a fair die. A score above `0.5` indicates that the model is doing better than chance, while a score below `0.5` indicates that the model is doing worse than chance.\n\nThis metric has three separate use cases:\n    - binary: The case in which there are only two different label classes, and each example gets only one label. This is the default implementation.\n    - multiclass: The case in which there can be more than two different label classes, but each example still gets only one label.\n    - multilabel: The case in which there can be more than two different label classes, and each example can have more than one label.\n'

a		:					int    	=					'\nArgs:\n- references (array-like of shape (n_samples,) or (n_samples, n_classes)): Ground truth labels. Expects different input based on use case:\n    - binary: expects an array-like of shape (n_samples,)\n    - multiclass: expects an array-like of shape (n_samples,)\n    - multilabel: expects an array-like of shape (n_samples, n_classes)\n- prediction_scores (array-like of shape (n_samples,) or (n_samples, n_classes)): Model predictions. Expects different inputs based on use case:\n    - binary: expects an array-like of shape (n_samples,)\n    - multiclass: expects an array-like of shape (n_samples, n_classes)\n    - multilabel: expects an array-like of shape (n_samples, n_classes)\n- average (`str`): Type of average, and is ignored in the binary use case. Defaults to \'macro\'. Options are:\n    - `\'micro\'`: Calculates metrics globally by considering each element of the label indicator matrix as a label. Only works with the multilabel use case.\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 (i.e. the number of true instances for each label).\n    - `\'samples\'`: Calculate metrics for each instance, and find their average. Only works with the multilabel use case.\n    - `None`:  No average is calculated, and scores for each class are returned. Only works with the multilabels use case.\n- sample_weight (array-like of shape (n_samples,)): Sample weights. Defaults to None.\n- max_fpr (`float`): If not None, the standardized partial AUC over the range [0, `max_fpr`] is returned. Must be greater than `0` and less than or equal to `1`. Defaults to `None`. Note: For the multiclass use case, `max_fpr` should be either `None` or `1.0` as ROC AUC partial computation is not currently supported for `multiclass`.\n- multi_class (`str`): Only used for multiclass targets, where it is required. Determines the type of configuration to use. Options are:\n    - `\'ovr\'`: Stands for One-vs-rest. Computes the AUC of each class against the rest. This treats the multiclass case in the same way as the multilabel case. Sensitive to class imbalance even when `average == \'macro\'`, because class imbalance affects the composition of each of the \'rest\' groupings.\n    - `\'ovo\'`: Stands for One-vs-one. Computes the average AUC of all possible pairwise combinations of classes. Insensitive to class imbalance when `average == \'macro\'`.\n- labels (array-like of shape (n_classes,)): Only used for multiclass targets. List of labels that index the classes in\n    `prediction_scores`. If `None`, the numerical or lexicographical order of the labels in\n    `prediction_scores` is used. Defaults to `None`.\nReturns:\n    roc_auc (`float` or array-like of shape (n_classes,)): Returns array if in multilabel use case and `average=\'None\'`. Otherwise, returns `float`.\nExamples:\n    Example 1:\n        >>> roc_auc_score = datasets.load_metric("roc_auc")\n        >>> refs = [1, 0, 1, 1, 0, 0]\n        >>> pred_scores = [0.5, 0.2, 0.99, 0.3, 0.1, 0.7]\n        >>> results = roc_auc_score.compute(references=refs, prediction_scores=pred_scores)\n        >>> print(round(results[\'roc_auc\'], 2))\n        0.78\n\n    Example 2:\n        >>> roc_auc_score = datasets.load_metric("roc_auc", "multiclass")\n        >>> refs = [1, 0, 1, 2, 2, 0]\n        >>> pred_scores = [[0.3, 0.5, 0.2],\n        ...                 [0.7, 0.2, 0.1],\n        ...                 [0.005, 0.99, 0.005],\n        ...                 [0.2, 0.3, 0.5],\n        ...                 [0.1, 0.1, 0.8],\n        ...                 [0.1, 0.7, 0.2]]\n        >>> results = roc_auc_score.compute(references=refs, prediction_scores=pred_scores, multi_class=\'ovr\')\n        >>> print(round(results[\'roc_auc\'], 2))\n        0.85\n\n    Example 3:\n        >>> roc_auc_score = datasets.load_metric("roc_auc", "multilabel")\n        >>> refs = [[1, 1, 0],\n        ...         [1, 1, 0],\n        ...         [0, 1, 0],\n        ...         [0, 0, 1],\n        ...         [0, 1, 1],\n        ...         [1, 0, 1]]\n        >>> pred_scores = [[0.3, 0.5, 0.2],\n        ...                 [0.7, 0.2, 0.1],\n        ...                 [0.005, 0.99, 0.005],\n        ...                 [0.2, 0.3, 0.5],\n        ...                 [0.1, 0.1, 0.8],\n        ...                 [0.1, 0.7, 0.2]]\n        >>> results = roc_auc_score.compute(references=refs, prediction_scores=pred_scores, average=None)\n        >>> print([round(res, 2) for res in results[\'roc_auc\']])\n        [0.83, 0.38, 0.94]\n'

a		:					List[Any]    	=					'\\n@article{doi:10.1177/0272989X8900900307,\nauthor = {Donna Katzman McClish},\ntitle ={Analyzing a Portion of the ROC Curve},\njournal = {Medical Decision Making},\nvolume = {9},\nnumber = {3},\npages = {190-195},\nyear = {1989},\ndoi = {10.1177/0272989X8900900307},\n    note ={PMID: 2668680},\nURL = {https://doi.org/10.1177/0272989X8900900307},\neprint = {https://doi.org/10.1177/0272989X8900900307}\n}\n\n\n@article{10.1023/A:1010920819831,\nauthor = {Hand, David J. and Till, Robert J.},\ntitle = {A Simple Generalisation of the Area Under the ROC Curve for Multiple Class Classification Problems},\nyear = {2001},\nissue_date = {November 2001},\npublisher = {Kluwer Academic Publishers},\naddress = {USA},\nvolume = {45},\nnumber = {2},\nissn = {0885-6125},\nurl = {https://doi.org/10.1023/A:1010920819831},\ndoi = {10.1023/A:1010920819831},\njournal = {Mach. Learn.},\nmonth = {oct},\npages = {171–186},\nnumpages = {16},\nkeywords = {Gini index, AUC, error rate, ROC curve, receiver operating characteristic}\n}\n\n\n@article{scikit-learn,\ntitle={Scikit-learn: Machine Learning in {P}ython},\nauthor={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.},\njournal={Journal of Machine Learning Research},\nvolume={12},\npages={2825--2830},\nyear={2011}\n}\n'







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



     def  lowercase__     (       self      )		->    str:







         """simple docstring"""



         return datasets.MetricInfo(
             description=_DESCRIPTION    ,							citation=_CITATION    ,							inputs_description=_KWARGS_DESCRIPTION    ,							features=datasets.Features(
                 {
                     'prediction_scores': datasets.Sequence(datasets.Value('float'      )      ),
                     'references': datasets.Value('int32'      ),
                 }
                 if self.config_name == 'multiclass'
                 else {
                     'references': datasets.Sequence(datasets.Value('int32'      )      ),
                     'prediction_scores': datasets.Sequence(datasets.Value('float'      )      ),
                 }
                 if self.config_name == 'multilabel'
                 else {
                     'references': datasets.Value('int32'      ),
                     'prediction_scores': datasets.Value('float'      ),
                 }      )    ,							reference_urls=['https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html']    ,							)




     def  lowercase__     (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE="macro"    ,							__SCREAMING_SNAKE_CASE=None    ,							__SCREAMING_SNAKE_CASE=None    ,							__SCREAMING_SNAKE_CASE="raise"    ,							__SCREAMING_SNAKE_CASE=None    ,							)		->    Any:







         """simple docstring"""



         return {
             "roc_auc": roc_auc_score(
                 __SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							average=__SCREAMING_SNAKE_CASE    ,							sample_weight=__SCREAMING_SNAKE_CASE    ,							max_fpr=__SCREAMING_SNAKE_CASE    ,							multi_class=__SCREAMING_SNAKE_CASE    ,							labels=__SCREAMING_SNAKE_CASE    ,							)
         }


