code: def nce(
      y_true: Union[List[int], np.ndarray],
      y_score: Union[List[float], np.ndarray],
  ) -> float:
      """Compute Normalized Cross Entropy (NCE) from prediction scores. Also known as the Normalized Mutual Information.
  
      NCE measures how close the correct prediction scores are to one and the incorrect prediction scores are to zero.
      Negative NCE values indicate that the classifier performs worse than the setting all prediction scores
      as the proportion of correct predictions.
  
      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 -math.inf
      p = y_true.mean()
      eps = 1e-15
      Hp = -(math.log(p + eps) * p + math.log(1 - p + eps) * (1 - p))
      return (Hp - log_loss(y_true, y_score)) / Hp
  
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 4 for calling a global function with example usage: nce(y_true, y_score) and returns: unknown, unknown