code: def auc_roc(
      y_true: Union[List[int], np.ndarray],
      y_score: Union[List[float], np.ndarray],
  ) -> float:
      """Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores.
  
      Note: If only one class is present in y_true, 0.5 is returned.
      """
      y_true = np.array(y_true)
      y_score = np.array(y_score)
      assert len(y_true) == len(y_score)
      assert np.all(y_true >= 0) and np.all(y_true <= 1)
      if np.all(y_true == 0) or np.all(y_true == 1):
          return 0.5
      return roc_auc_score(y_true, y_score)
  
file_path: NeMo/nemo/collections/asr/parts/utils/confidence_metrics.py
imports: import math
  import os
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  from sklearn.metrics import PrecisionRecallDisplay, RocCurveDisplay, average_precision_score, log_loss, precision_recall_curve, roc_auc_score, roc_curve
label_desc: Use image node_id 1 for calling a global function with example usage: auc_roc(y_true, y_score) and returns: roc_auc_score, int