code: def lovasz_grad(gt_sorted):
      """Computes gradient of the Lovasz extension w.r.t sorted errors.
  
      See Alg. 1 in paper.
      """
      p = len(gt_sorted)
      gts = gt_sorted.sum()
      intersection = gts - gt_sorted.float().cumsum(0)
      union = gts + (1 - gt_sorted).float().cumsum(0)
      jaccard = 1.0 - intersection / union
      if p > 1:  # cover 1-pixel case
          jaccard[1:p] = jaccard[1:p] - jaccard[0:-1]
      return jaccard
  
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 1 for calling a global function with example usage: lovasz_grad(gt_sorted) and returns: jaccard