code: def get_labels(
      cid_tid_dict,
      cid_tids,
      use_ff=True,
      use_rerank=True,
      use_st_filter=False,
  ):
      try:
          from sklearn.cluster import AgglomerativeClustering
      except Exception as e:
          raise RuntimeError(
              "Unable to use sklearn in MTMCT in PP-Tracking, please install sklearn, for example: `pip install sklearn`"
          )
      # 1st cluster
      sim_matrix = get_sim_matrix(
          cid_tid_dict,
          cid_tids,
          use_ff=use_ff,
          use_rerank=use_rerank,
          use_st_filter=use_st_filter,
      )
      cluster_labels = AgglomerativeClustering(
          n_clusters=None,
          distance_threshold=0.5,
          affinity="precomputed",
          linkage="complete",
      ).fit_predict(1 - sim_matrix)
      labels = get_match(cluster_labels)
      sub_cluster = get_cid_tid(labels, cid_tids)
  
      # 2nd cluster
      cid_tid_dict_new = combin_feature(cid_tid_dict, sub_cluster)
      sim_matrix = get_sim_matrix(
          cid_tid_dict_new,
          cid_tids,
          use_ff=use_ff,
          use_rerank=use_rerank,
          use_st_filter=use_st_filter,
      )
      cluster_labels = AgglomerativeClustering(
          n_clusters=None,
          distance_threshold=0.9,
          affinity="precomputed",
          linkage="complete",
      ).fit_predict(1 - sim_matrix)
      labels = get_match(cluster_labels)
      sub_cluster = get_cid_tid(labels, cid_tids)
  
      return labels
  
imports: import os
  import re
  import cv2
  import gc
  import numpy
  import pandas
  from tqdm import tqdm
  import warnings
label_desc: Use image node_id 28 for calling a global function with example usage: get_labels(cid_tid_dict, cid_tids, use_ff, use_rerank, use_st_filter) and returns: labels