code: def test_auc_computation(self, device: str):
      auc = Auc()
      all_predictions = []
      all_labels = []
      for _ in range(5):
          predictions = torch.randn(8, device=device)
          labels = torch.randint(
              0, 2, (8,), dtype=torch.long, device=device
          )
  
          auc(predictions, labels)
  
          all_predictions.append(predictions)
          all_labels.append(labels)
  
      computed_auc_value = auc.get_metric(reset=True)
  
      false_positive_rates, true_positive_rates, _ = metrics.roc_curve(
          torch.cat(all_labels, dim=0).cpu().numpy(),
          torch.cat(all_predictions, dim=0).cpu().numpy(),
      )
      real_auc_value = metrics.auc(
          false_positive_rates, true_positive_rates
      )
      assert_allclose(real_auc_value, computed_auc_value)
  
      # One more computation to assure reset works.
      predictions = torch.randn(8, device=device)
      labels = torch.randint(
          0, 2, (8,), dtype=torch.long, device=device
      )
  
      auc(predictions, labels)
      computed_auc_value = auc.get_metric(reset=True)
  
      false_positive_rates, true_positive_rates, _ = metrics.roc_curve(
          labels.cpu().numpy(), predictions.cpu().numpy()
      )
      real_auc_value = metrics.auc(
          false_positive_rates, true_positive_rates
      )
      assert_allclose(real_auc_value, computed_auc_value)
  
file_path: allennlp/tests/training/metrics/auc_test.py
imports: import pytest
  import torch
  from sklearn import metrics
  from torch.testing import assert_allclose
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase, multi_device, global_distributed_metric, run_distributed_test
  from allennlp.training.metrics import Auc
label_desc: Use image node_id 1 for calling the AucTest obj's underlying member method code with example usage: obj.test_auc_computation(device) without return types