code: def lovasz_softmax_flat(
      probs, labels, classes="present", class_weight=None
  ):
      """Multi-class Lovasz-Softmax loss.
  
      Args:
          probs (torch.Tensor): [P, C], class probabilities at each prediction
              (between 0 and 1).
          labels (torch.Tensor): [P], ground truth labels (between 0 and C - 1).
          classes (str | list[int], optional): Classes chosen to calculate loss.
              'all' for all classes, 'present' for classes present in labels, or
              a list of classes to average. Default: 'present'.
          class_weight (list[float], optional): The weight for each class.
              Default: None.
  
      Returns:
          torch.Tensor: The calculated loss.
      """
      if probs.numel() == 0:
          # only void pixels, the gradients should be 0
          return probs * 0.0
      C = probs.size(1)
      losses = []
      class_to_sum = (
          list(range(C)) if classes in ["all", "present"] else classes
      )
      for c in class_to_sum:
          fg = (labels == c).float()  # foreground for class c
          if classes == "present" and fg.sum() == 0:
              continue
          if C == 1:
              if len(classes) > 1:
                  raise ValueError(
                      "Sigmoid output possible only with 1 class"
                  )
              class_pred = probs[:, 0]
          else:
              class_pred = probs[:, c]
          errors = (fg - class_pred).abs()
          errors_sorted, perm = torch.sort(errors, 0, descending=True)
          perm = perm.data
          fg_sorted = fg[perm]
          loss = torch.dot(errors_sorted, lovasz_grad(fg_sorted))
          if class_weight is not None:
              loss *= class_weight[c]
          losses.append(loss)
      return torch.stack(losses).mean()
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/losses/lovasz_loss.py
imports: import annotator.uniformer.mmcv
  import torch
  import torch.nn
  import torch.nn.functional
  from ..builder import LOSSES
  from .utils import get_class_weight, weight_reduce_loss
label_desc: Use image node_id 6 for calling a global function with example usage: lovasz_softmax_flat(probs, labels, classes, class_weight) and returns: torch, unknown