code: def get_classifications(
      preds: Sequence[np.ndarray],
      pred_spec: types.MulticlassPreds,
      margin_config: Optional[Sequence[float]] = None,
  ) -> Sequence[int]:
      """Get predicted class indices given prediction scores and configs."""
      # If there is a margin set for the prediction, take the log of the prediction
      # scores and add the margin to the null indexes value before taking argmax
      # to find the predicted class.
      if margin_config is not None:
          null_idx = pred_spec.null_idx
          pred_idxs = []
          null_idx_one_hot = np.eye(len(pred_spec.vocab))[null_idx]
          for p, margin in zip(preds, margin_config):
              logit_mask = margin * null_idx_one_hot
              pred_idx = np.argmax(np.log(p) + logit_mask)
              pred_idxs.append(pred_idx)
      else:
          pred_idxs = [np.argmax(p) for p in preds]
      return pred_idxs
  
file_path: lit/lit_nlp/components/classification_results.py
imports: from collections.abc import Sequence
  import numbers
  from typing import cast, Optional
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import dtypes
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import utils
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: get_classifications(preds, pred_spec, margin_config) and returns: pred_idxs