code: def get_total_loss(self, pos_score, neg_score, edge_weight=None):
      log = {}
      if edge_weight is None:
          edge_weight = 1
      if self.pairwise:
          pos_score = pos_score.unsqueeze(-1)
          loss = th.mean(
              self.loss_criterion((pos_score - neg_score), 1)
              * edge_weight
          )
          log["loss"] = get_scalar(loss)
          return loss, log
  
      pos_loss = self._get_pos_loss(pos_score) * edge_weight
      neg_loss = self._get_neg_loss(neg_score) * edge_weight
      # MARK - would average twice make loss function lose precision?
      # do mean over neg_sample
      if self.neg_adversarial_sampling:
          neg_loss = th.sum(
              th.softmax(
                  neg_score * self.adversarial_temperature, dim=-1
              ).detach()
              * neg_loss,
              dim=-1,
          )
      else:
          neg_loss = th.mean(neg_loss, dim=-1)
      # do mean over chunk
      neg_loss = th.mean(neg_loss)
      pos_loss = th.mean(pos_loss)
      loss = (neg_loss + pos_loss) / 2
      log["pos_loss"] = get_scalar(pos_loss)
      log["neg_loss"] = get_scalar(neg_loss)
      log["loss"] = get_scalar(loss)
      return loss, log
  
imports: from ..base_loss import *
  from .tensor_models import *
  import torch
  import torch.nn.functional
label_desc: Use image node_id 4 for calling the LossGenerator obj's underlying member method code with example usage: obj.get_total_loss(pos_score, neg_score, edge_weight) and returns: loss,  log, loss,  log