code: def cross_entropy_with_weight(logits, labels):
      logits = logits.view(-1)
      labels = labels.view(-1)
      eps = 1e-6  # 1e-6 is the good choise if smaller than 1e-6, it may appear NaN
      pred_pos = logits[labels > 0].clamp(eps, 1.0 - eps)
      pred_neg = logits[labels == 0].clamp(eps, 1.0 - eps)
      w_anotation = labels[labels > 0]
      # weight_pos, weight_neg = get_weight(labels, labels, 0.5, 1.5)
      cross_entropy = (-pred_pos.log() * w_anotation).mean() + (
          -(1.0 - pred_neg).log()
      ).mean()
      # cross_entropy = (-pred_pos.log() * weight_pos).sum() + \
      #                     (-(1.0 - pred_neg).log() * weight_neg).sum()
      return cross_entropy
  
imports: import torch.nn.functional
  from .utils import *
  from .backbone import *
label_desc: Use image node_id 4 for calling a global function with example usage: cross_entropy_with_weight(logits, labels) and returns: cross_entropy