code: def forward(self, pred, batch):
      node_preds, edge_preds = pred
      gts, tag = batch[4], batch[5]
      gts = self.pre_process(gts, tag)
      node_gts, edge_gts = [], []
      for gt in gts:
          node_gts.append(gt[:, 0])
          edge_gts.append(gt[:, 1:].reshape([-1]))
      node_gts = paddle.concat(node_gts)
      edge_gts = paddle.concat(edge_gts)
  
      node_valids = paddle.nonzero(node_gts != self.ignore).reshape(
          [-1]
      )
      edge_valids = paddle.nonzero(edge_gts != -1).reshape([-1])
      loss_node = self.loss_node(node_preds, node_gts)
      loss_edge = self.loss_edge(edge_preds, edge_gts)
      loss = self.node_weight * loss_node + self.edge_weight * loss_edge
      return dict(
          loss=loss,
          loss_node=loss_node,
          loss_edge=loss_edge,
          acc_node=self.accuracy(
              paddle.gather(node_preds, node_valids),
              paddle.gather(node_gts, node_valids),
          ),
          acc_edge=self.accuracy(
              paddle.gather(edge_preds, edge_valids),
              paddle.gather(edge_gts, edge_valids),
          ),
      )
  
file_path: PaddleOCR/ppocr/losses/kie_sdmgr_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from paddle import nn
  import paddle
label_desc: Use image node_id 4 for calling the SDMGRLoss obj's underlying member method code with example usage: obj.forward(pred, batch) and returns: dict