code: def get_normalized_margin_for_each_label(
      labels: np.ndarray,
      pred_probs: np.ndarray,
  ) -> np.ndarray:
      """Returns the "normalized margin" label-quality score for each datapoint.
  
      This is a function to compute label-quality scores for classification datasets,
      where lower scores indicate labels less likely to be correct.
  
      Letting ``k`` denote the given label for a datapoint, the margin is
      ``(p(label = k) - max(p(label != k)))``, i.e. the probability
      of the given label minus the probability of the argmax label that is not
      the given label (``margin = prob_label - max_prob_not_label``).
      This gives you an idea of how likely an example is BOTH its given label AND not another label,
      and therefore, scores its likelihood of being a good label or a label error.
      The normalized margin is simply a transformed version of the margin,
      to ensure values between 0-1 with lower values indicating more likely mislabeled data.
  
      Normalized margin works best for finding class conditional label errors where
      there is another label in the set of classes that is clearly better than the given label.
  
      Parameters
      ----------
      labels : np.ndarray
        Labels in the same format expected by the `~cleanlab.rank.get_label_quality_scores` function.
  
      pred_probs : np.ndarray
        Predicted-probabilities in the same format expected by the `~cleanlab.rank.get_label_quality_scores` function.
  
      Returns
      -------
      label_quality_scores : np.ndarray
        Contains one score (between 0 and 1) per example.
        Lower scores indicate more likely mislabeled examples.
      """
  
      self_confidence = get_self_confidence_for_each_label(
          labels, pred_probs
      )
      N, K = pred_probs.shape
      del_indices = np.arange(N) * K + labels
      max_prob_not_label = np.max(
          np.delete(pred_probs, del_indices, axis=None).reshape(
              N, K - 1
          ),
          axis=-1,
      )
      label_quality_scores = (
          self_confidence - max_prob_not_label + 1
      ) / 2
      return label_quality_scores
  
file_path: cleanlab/cleanlab/rank.py
imports: import numpy
  from sklearn.metrics import log_loss
  from typing import List, Optional
  import warnings
  from cleanlab.internal.validation import assert_valid_inputs
  from cleanlab.internal.constants import CLIPPING_LOWER_BOUND
  from cleanlab.internal.label_quality_utils import _subtract_confident_thresholds, get_normalized_entropy
label_desc: Use image node_id 7 for calling a global function with example usage: get_normalized_margin_for_each_label(labels, pred_probs) and returns: label_quality_scores