code: def forward(self, preds, batch):
      imgs = batch[0]
      out = preds["maps"]
      (
          gt_kernels,
          training_masks,
          gt_instances,
          gt_kernel_instances,
          training_mask_distances,
          gt_distances,
      ) = batch[1:]
  
      kernels = out[:, 0, :, :]
      distances = out[:, 1:, :, :]
  
      # kernel loss
      selected_masks = ohem_batch(kernels, gt_kernels, training_masks)
  
      loss_kernel = self.kernel_loss(
          kernels, gt_kernels, selected_masks, reduce=False
      )
  
      iou_kernel = iou(
          paddle.cast((kernels > 0), "int64"),
          gt_kernels,
          training_masks,
          reduce=False,
      )
      losses = dict(
          loss_kernels=loss_kernel,
      )
  
      # loc loss
      loss_loc, iou_text = self.loc_loss(
          distances,
          gt_instances,
          gt_kernel_instances,
          training_mask_distances,
          gt_distances,
          reduce=False,
      )
      losses.update(
          dict(
              loss_loc=loss_loc,
          )
      )
  
      loss_all = loss_kernel + loss_loc
      losses = {"loss": loss_all}
  
      return losses
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import nn
  import paddle.nn.functional
  import numpy
label_desc: Use image node_id 2 for calling the CTLoss obj's underlying member method code with example usage: obj.forward(preds, batch) and returns: losses