code: def lovasz_hinge(logits, labels, per_image=True, ignore=None):
      """
      Binary Lovasz hinge loss
        logits: [B, H, W] Variable, logits at each pixel (between -\infty and +\infty)
        labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)
        per_image: compute the loss per image instead of per batch
        ignore: void class id
      """
      if per_image:
          loss = mean(
              lovasz_hinge_flat(
                  *flatten_binary_scores(
                      log.unsqueeze(0), lab.unsqueeze(0), ignore
                  )
              )
              for log, lab in zip(logits, labels)
          )
      else:
          loss = lovasz_hinge_flat(
              *flatten_binary_scores(logits, labels, ignore)
          )
      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 4 for calling a global function with example usage: lovasz_hinge(logits, labels, per_image, ignore) and returns: loss