code: def lovasz_softmax(
      probas,
      labels,
      classes="present",
      per_image=False,
      ignore=255,
      weighted=None,
  ):
      """
      Multi-class Lovasz-Softmax loss
        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].
        labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
        classes: 'all' for all, 'present' for classes present in labels, or a list of classes to average.
        per_image: compute the loss per image instead of per batch
        ignore: void class labels
      """
      if per_image:
          loss = mean(
              lovasz_softmax_flat(
                  *flatten_probas(
                      prob.unsqueeze(0), lab.unsqueeze(0), ignore
                  ),
                  classes=classes,
                  weighted=weighted,
              )
              for prob, lab in zip(probas, labels)
          )
      else:
          loss = lovasz_softmax_flat(
              *flatten_probas(probas, labels, ignore),
              classes=classes,
              weighted=weighted,
          )
      return loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.autograd import Variable
label_desc: Use image node_id 8 for calling a global function with example usage: lovasz_softmax(probas, labels, classes, per_image, ignore, weighted) and returns: loss