code: def calc_loss(self, scores: Scores, batch_edges: EdgeList):
      lhs_loss = self.loss_fn(
          scores.lhs_pos, scores.lhs_neg, batch_edges.weight
      )
      rhs_loss = self.loss_fn(
          scores.rhs_pos, scores.rhs_neg, batch_edges.weight
      )
      relation = (
          batch_edges.get_relation_type_as_scalar()
          if batch_edges.has_scalar_relation_type()
          else 0
      )
      loss = self.relation_weights[relation] * (lhs_loss + rhs_loss)
  
      return loss
  
file_path: PyTorch-BigGraph/torchbiggraph/batching.py
imports: import time
  from abc import ABC, abstractmethod
  from typing import Any, Callable, Dict, Iterable, List, Optional
  import torch
  from torchbiggraph.edgelist import EdgeList
  from torchbiggraph.losses import AbstractLossFunction
  from torchbiggraph.model import MultiRelationEmbedder, override_model, Scores
  from torchbiggraph.stats import Stats
  from torchbiggraph.types import LongTensorType
label_desc: Use image node_id 2 for calling the AbstractBatchProcessor obj's underlying member method code with example usage: obj.calc_loss(scores, batch_edges) and returns: loss