code: def write_mot_results(
      filename, results, data_type="mot", num_classes=1
  ):
      # support single and multi classes
      if data_type in ["mot", "mcmot"]:
          save_format = (
              "{frame},{id},{x1},{y1},{w},{h},{score},{cls_id},-1,-1\n"
          )
      elif data_type == "kitti":
          save_format = "{frame} {id} car 0 0 -10 {x1} {y1} {x2} {y2} -10 -10 -10 -1000 -1000 -1000 -10\n"
      else:
          raise ValueError(data_type)
  
      f = open(filename, "w")
      for cls_id in range(num_classes):
          for frame_id, tlwhs, tscores, track_ids in results[cls_id]:
              if data_type == "kitti":
                  frame_id -= 1
              for tlwh, score, track_id in zip(
                  tlwhs, tscores, track_ids
              ):
                  if track_id < 0:
                      continue
                  if data_type == "mot":
                      cls_id = -1
  
                  x1, y1, w, h = tlwh
                  x2, y2 = x1 + w, y1 + h
                  line = save_format.format(
                      frame=frame_id,
                      id=track_id,
                      x1=x1,
                      y1=y1,
                      x2=x2,
                      y2=y2,
                      w=w,
                      h=h,
                      score=score,
                      cls_id=cls_id,
                  )
                  f.write(line)
      print("MOT results save in {}".format(filename))
  
imports: import os
  import cv2
  import time
  import numpy
  import collections
  import math
label_desc: Use image node_id 1 for calling a global function with example usage: write_mot_results(filename, results, data_type, num_classes) without return types