code: def mot_topdown_unite_predict(
      mot_detector,
      topdown_keypoint_detector,
      image_list,
      keypoint_batch_size=1,
      save_res=False,
  ):
      det_timer = mot_detector.get_timer()
      store_res = []
      image_list.sort()
      num_classes = mot_detector.num_classes
      for i, img_file in enumerate(image_list):
          # Decode image in advance in mot + pose prediction
          det_timer.preprocess_time_s.start()
          image, _ = decode_image(img_file, {})
          det_timer.preprocess_time_s.end()
  
          if FLAGS.run_benchmark:
              mot_results = mot_detector.predict_image(
                  [image], run_benchmark=True, repeats=10
              )
  
              cm, gm, gu = get_current_memory_mb()
              mot_detector.cpu_mem += cm
              mot_detector.gpu_mem += gm
              mot_detector.gpu_util += gu
          else:
              mot_results = mot_detector.predict_image(
                  [image], visual=False
              )
  
          online_tlwhs, online_scores, online_ids = mot_results[
              0
          ]  # only support bs=1 in MOT model
          results = convert_mot_to_det(
              online_tlwhs[0], online_scores[0]
          )  # only support single class for mot + pose
          if results["boxes_num"] == 0:
              continue
  
          keypoint_res = predict_with_given_det(
              image,
              results,
              topdown_keypoint_detector,
              keypoint_batch_size,
              FLAGS.run_benchmark,
          )
  
          if save_res:
              save_name = img_file if isinstance(img_file, str) else i
              store_res.append(
                  [
                      save_name,
                      keypoint_res["bbox"],
                      [
                          keypoint_res["keypoint"][0],
                          keypoint_res["keypoint"][1],
                      ],
                  ]
              )
          if FLAGS.run_benchmark:
              cm, gm, gu = get_current_memory_mb()
              topdown_keypoint_detector.cpu_mem += cm
              topdown_keypoint_detector.gpu_mem += gm
              topdown_keypoint_detector.gpu_util += gu
          else:
              if not os.path.exists(FLAGS.output_dir):
                  os.makedirs(FLAGS.output_dir)
              visualize_pose(
                  img_file,
                  keypoint_res,
                  visual_thresh=FLAGS.keypoint_threshold,
                  save_dir=FLAGS.output_dir,
              )
  
      if save_res:
          """
          1) store_res: a list of image_data
          2) image_data: [imageid, rects, [keypoints, scores]]
          3) rects: list of rect [xmin, ymin, xmax, ymax]
          4) keypoints: 17(joint numbers)*[x, y, conf], total 51 data in list
          5) scores: mean of all joint conf
          """
          with open("det_keypoint_unite_image_results.json", "w") as wf:
              json.dump(store_res, wf, indent=4)
  
imports: import os
  import json
  import cv2
  import math
  import numpy
  import paddle
  import yaml
  import copy
  from collections import defaultdict
  from mot_keypoint_unite_utils import argsparser
  from preprocess import decode_image
  from infer import print_arguments, get_test_images, bench_log
  from mot_sde_infer import SDE_Detector
  from mot_jde_infer import JDE_Detector, MOT_JDE_SUPPORT_MODELS
  from keypoint_infer import KeyPointDetector, KEYPOINT_SUPPORT_MODELS
  from det_keypoint_unite_infer import predict_with_given_det
  from visualize import visualize_pose
  from benchmark_utils import PaddleInferBenchmark
  from utils import get_current_memory_mb
  from keypoint_postprocess import translate_to_ori_images
  import sys
  from pptracking.python.mot.visualize import plot_tracking, plot_tracking_dict
  from pptracking.python.mot.utils import MOTTimer
label_desc: Use image node_id 2 for calling a global function with example usage: mot_topdown_unite_predict(mot_detector, topdown_keypoint_detector, image_list, keypoint_batch_size, save_res) without return types