code: def _SVM_loss(
      multiclass_classifier: ActiveLearner,
      X: modALinput,
      most_certain_classes: Optional[int] = None,
  ) -> np.ndarray:
      """
      Utility function for max_loss and mean_max_loss strategies.
  
      Args:
          multiclass_classifier: sklearn.multiclass.OneVsRestClassifier instance for which the loss
              is to be calculated.
          X: The pool of samples to query from.
          most_certain_classes: optional, indexes of most certainly predicted class for each instance.
              If None, loss is calculated for all classes.
  
      Returns:
          np.ndarray of shape (n_instances, ), losses for the instances in X.
  
      """
      predictions = 2 * multiclass_classifier.predict(X) - 1
      n_classes = len(multiclass_classifier.classes_)
  
      if most_certain_classes is None:
          cls_mtx = 2 * np.eye(n_classes, n_classes) - 1
          loss_mtx = np.maximum(1 - np.dot(predictions, cls_mtx), 0)
          return loss_mtx.mean(axis=1)
      else:
          cls_mtx = -np.ones(shape=(len(X), n_classes))
          for inst_idx, most_certain_class in enumerate(
              most_certain_classes
          ):
              cls_mtx[inst_idx, most_certain_class] = 1
  
          cls_loss = np.maximum(
              1 - np.multiply(cls_mtx, predictions), 0
          ).sum(axis=1)
          return cls_loss
  
file_path: modAL/modAL/multilabel.py
imports: from typing import Optional
  import numpy
  from sklearn.multiclass import OneVsRestClassifier
  from modAL.models import ActiveLearner
  from modAL.utils.data import modALinput
  from modAL.utils.selection import multi_argmax, multi_argmin, shuffled_argmax, shuffled_argmin
label_desc: Use image node_id 1 for calling a global function with example usage: _SVM_loss(multiclass_classifier, X, most_certain_classes) and returns: loss_mtx, cls_loss