code: def calculate_losses(self, pred, label):
      heatmap = label["heatmap"]
      heatmap_weight = label["heatmap_weight"]
      offset = label["offset"] / self.offset_rescale_factor
      offset_weight = label["offset_weight"]
  
      heatmap_pred = pred["heatmap"]
      offset_pred = pred["offset"]
  
      heatmap_loss = F.binary_cross_entropy_with_logits(
          heatmap_pred, heatmap, reduction="none"
      )
      heatmap_loss = (heatmap_loss * heatmap_weight).mean(dim=(1, 2, 3))
      offset_loss = F.mse_loss(offset_pred, offset, reduction="none")
      offset_loss = (offset_loss * offset_weight).mean(
          dim=(1, 2, 3)
      ) * self.offset_ratio
  
      return {
          "heatmap_loss": heatmap_loss,
          "offset_loss": offset_loss,
      }
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from backbones.upsample_head import SimpleUpsampleHead
label_desc: Use image node_id 4 for calling the SimpleMSRDecoder obj's underlying member method code with example usage: obj.calculate_losses(pred, label) and returns: dict