docs: def do_confusion_matrix(sorting1, sorting2, unit_map12, labels_st1, labels_st2):
      """
      Compute the confusion matrix between two sorting.
      
      Parameters
      ----------
      sorting1: SortingExtractor instance
          The ground truth sorting.
      
      sorting2: SortingExtractor instance
          The tested sorting.
  
      unit_map12: dict
          Dict of matching from sorting1 to sorting2.
          
  
      Output
      ----------
      
      confusion_matrix: the confusion matrix
      
      st1_idxs: order of units1 in confusion matrix
      
      
      st2_idxs: order of units2 in confusion matrix
      
      
      """
  
      unit1_ids = np.array(sorting1.get_unit_ids())
      unit2_ids = np.array(sorting2.get_unit_ids())
      N1 = len(unit1_ids)
      N2 = len(unit2_ids)
      
      conf_matrix = np.zeros((N1 + 1, N2 + 1), dtype=int)
      
      mapped_units = np.array(list(unit_map12.values()))
      idxs_matched, = np.where(mapped_units != -1)
      idxs_unmatched, = np.where(mapped_units == -1)
      unit_map_matched = mapped_units[idxs_matched]
  
      st1_idxs =np.hstack([unit1_ids[idxs_matched], unit1_ids[idxs_unmatched]])
      st2_matched = unit_map_matched
      st2_unmatched = []
  
      for u_i, u1 in enumerate(unit1_ids[idxs_matched]):
          lab_st1 = labels_st1[u1]
          tp = len(np.where('TP' == lab_st1)[0])
          conf_matrix[u_i, u_i] = int(tp)
          for u_j, u2 in enumerate(unit2_ids):
              lab_st2 = labels_st2[u2]
              cl_str = str(u1) + '_' + str(u2)
              cl = len([i for i, v in enumerate(lab_st1) if 'CL' in v and cl_str in v])
              if cl != 0:
                  st_p, = np.where(u2 == unit_map_matched)
                  conf_matrix[u_i, st_p] = int(cl)
          fn = len(np.where('FN' == lab_st1)[0])
          conf_matrix[u_i, -1] = int(fn)
  
      for u_i, u1 in enumerate(unit1_ids[idxs_unmatched]):
          lab_st1 = labels_st1[u1]
          fn = len(np.where('FN' == lab_st1)[0])
          conf_matrix[u_i + len(idxs_matched), -1] = int(fn)
  
      for u_j, u2 in enumerate(unit2_ids):
          lab_st2 = labels_st2[u2]
          fp = len(np.where('FP' == lab_st2)[0])
          st_p, = np.where(u2 == unit_map_matched)
          if len(st_p) != 0:
              conf_matrix[-1, st_p] = int(fp)
          else:
              st2_unmatched.append(int(u2))
              conf_matrix[-1, len(idxs_matched) + len(st2_unmatched) - 1] = int(fp)
      
      st2_idxs = np.hstack([st2_matched, st2_unmatched]).astype('int64')
  
      return conf_matrix,  st1_idxs, st2_idxs