code: def _lovasz_softmax(
      probas,
      labels,
      classes="present",
      per_image=False,
      ignore_index=None,
  ):
      """Multi-class Lovasz-Softmax loss
      Args:
          @param probas: [B, C, H, W] Variable, class probabilities at each prediction (between 0 and 1).
          Interpreted as binary (sigmoid) output with outputs of size [B, H, W].
          @param labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
          @param classes: 'all' for all, 'present' for classes present in labels, or a list of classes to average.
          @param per_image: compute the loss per image instead of per batch
          @param ignore_index: void class labels
      """
      if per_image:
          loss = mean(
              _lovasz_softmax_flat(
                  *_flatten_probas(
                      prob.unsqueeze(0), lab.unsqueeze(0), ignore_index
                  ),
                  classes=classes,
              )
              for prob, lab in zip(probas, labels)
          )
      else:
          loss = _lovasz_softmax_flat(
              *_flatten_probas(probas, labels, ignore_index),
              classes=classes,
          )
      return loss
  
imports: from __future__ import print_function, division
  from typing import Optional, Union
  import torch
  import torch.nn.functional
  from torch.autograd import Variable
  from torch.nn.modules.loss import _Loss
label_desc: Use image node_id 5 for calling a global function with example usage: _lovasz_softmax(probas, labels, classes, per_image, ignore_index) and returns: loss