code: def draw_kie_result(batch, node, idx_to_cls, count):
      img = batch[6].copy()
      boxes = batch[7]
      h, w = img.shape[:2]
      pred_img = np.ones((h, w * 2, 3), dtype=np.uint8) * 255
      max_value, max_idx = paddle.max(node, -1), paddle.argmax(node, -1)
      node_pred_label = max_idx.numpy().tolist()
      node_pred_score = max_value.numpy().tolist()
  
      for i, box in enumerate(boxes):
          if i >= len(node_pred_label):
              break
          new_box = [
              [box[0], box[1]],
              [box[2], box[1]],
              [box[2], box[3]],
              [box[0], box[3]],
          ]
          Pts = np.array([new_box], np.int32)
          cv2.polylines(
              img,
              [Pts.reshape((-1, 1, 2))],
              True,
              color=(255, 255, 0),
              thickness=1,
          )
          x_min = int(min([point[0] for point in new_box]))
          y_min = int(min([point[1] for point in new_box]))
  
          pred_label = node_pred_label[i]
          if pred_label in idx_to_cls:
              pred_label = idx_to_cls[pred_label]
          pred_score = "{:.2f}".format(node_pred_score[i])
          text = pred_label + "(" + pred_score + ")"
          cv2.putText(
              pred_img,
              text,
              (x_min * 2, y_min),
              cv2.FONT_HERSHEY_SIMPLEX,
              0.5,
              (255, 0, 0),
              1,
          )
      vis_img = np.ones((h, w * 3, 3), dtype=np.uint8) * 255
      vis_img[:, :w] = img
      vis_img[:, w:] = pred_img
      save_kie_path = (
          os.path.dirname(config["Global"]["save_res_path"])
          + "/kie_results/"
      )
      if not os.path.exists(save_kie_path):
          os.makedirs(save_kie_path)
      save_path = os.path.join(save_kie_path, str(count) + ".png")
      cv2.imwrite(save_path, vis_img)
      logger.info("The Kie Image saved in {}".format(save_path))
  
file_path: PaddleOCR/tools/infer_kie.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle.nn.functional
  import os
  import sys
  import cv2
  import paddle
  from ppocr.data import create_operators, transform
  from ppocr.modeling.architectures import build_model
  from ppocr.utils.save_load import load_model
  import tools.program
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: draw_kie_result(batch, node, idx_to_cls, count) without return types