code: def do_intra_matching(self, sub_zone_dict, sub_zone):
      new_zone_dict = dict()
      id_list = list(sub_zone_dict)
      id2index = dict()
      for index, id in enumerate(id_list):
          id2index[id] = index
  
      def get_trac_info(tracklet1):
          t1_f = list(tracklet1)
          t1_f.sort()
          t1_fs = t1_f[0]
          t1_fe = t1_f[-1]
          t1_zs = tracklet1[t1_fs]["zone"]
          t1_ze = tracklet1[t1_fe]["zone"]
          t1_boxs = tracklet1[t1_fs]["bbox"]
          t1_boxe = tracklet1[t1_fe]["bbox"]
          t1_boxs = [
              (t1_boxs[2] + t1_boxs[0]) / 2,
              (t1_boxs[3] + t1_boxs[1]) / 2,
          ]
          t1_boxe = [
              (t1_boxe[2] + t1_boxe[0]) / 2,
              (t1_boxe[3] + t1_boxe[1]) / 2,
          ]
          return t1_fs, t1_fe, t1_zs, t1_ze, t1_boxs, t1_boxe
  
      sim_matrix = np.zeros([len(id_list), len(id_list)])
  
      for t1id in sub_zone_dict:
          tracklet1 = sub_zone_dict[t1id]
          t1_fs, t1_fe, t1_zs, t1_ze, t1_boxs, t1_boxe = get_trac_info(
              tracklet1
          )
          t1_feat = tracklet1[t1_fe]["feat"]
          for t2id in sub_zone_dict:
              if t1id == t2id:
                  continue
              tracklet2 = sub_zone_dict[t2id]
              (
                  t2_fs,
                  t2_fe,
                  t2_zs,
                  t2_ze,
                  t2_boxs,
                  t2_boxe,
              ) = get_trac_info(tracklet2)
              if t1_zs != t1_ze and t2_ze != t2_zs or t1_fe > t2_fs:
                  continue
              if (
                  abs(t1_boxe[0] - t2_boxs[0]) > 50
                  or abs(t1_boxe[1] - t2_boxs[1]) > 50
              ):
                  continue
              if t2_fs - t1_fe > 5:
                  continue
              t2_feat = tracklet2[t2_fs]["feat"]
              sim_matrix[id2index[t1id], id2index[t2id]] = np.matmul(
                  t1_feat, t2_feat
              )
              sim_matrix[id2index[t2id], id2index[t1id]] = np.matmul(
                  t1_feat, t2_feat
              )
      sim_matrix = 1 - sim_matrix
      cluster_labels = AgglomerativeClustering(
          n_clusters=None,
          distance_threshold=0.7,
          affinity="precomputed",
          linkage="complete",
      ).fit_predict(sim_matrix)
      new_zone_dict = dict()
      label2id = dict()
      for index, label in enumerate(cluster_labels):
          tracklet = sub_zone_dict[id_list[index]]
          if label not in label2id:
              new_id = tracklet[list(tracklet)[0]]
              new_tracklet = dict()
          else:
              new_id = label2id[label]
              new_tracklet = new_zone_dict[label2id[label]]
          for tf in tracklet:
              tracklet[tf]["id"] = new_id
              new_tracklet[tf] = tracklet[tf]
          new_zone_dict[label] = new_tracklet
  
      return new_zone_dict
  
file_path: PaddleDetection/deploy/pptracking/python/mot/mtmct/zone.py
imports: import os
  import cv2
  import numpy
label_desc: Use image node_id 10 for calling the Zone obj's underlying member method code with example usage: obj.do_intra_matching(sub_zone_dict, sub_zone) and returns: new_zone_dict, t1_fs,  t1_fe,  t1_zs,  t1_ze,  t1_boxs,  t1_boxe