docs: def do_matching(sorting1, sorting2, delta_tp, min_accuracy):
      """
      This compute the matching between 2 sorters.
      
      Parameters
      ----------
      sorting1: SortingExtractor instance
      
      sorting2: SortingExtractor instance
      
      delta_tp: int
      
      
      Output
      ----------
      
      event_counts_1:
      
      event_counts_2
      
      matching_event_counts_12:
      
      best_match_units_12:
      
      matching_event_counts_21:
      
      best_match_units_21:
      
      unit_map12:
      
      unit_map21:
  
      
      """
      event_counts_1 = dict()
      event_counts_2 = dict()
      matching_event_counts_12 = dict()
      best_match_units_12 = dict()
      matching_event_counts_21 = dict()
      best_match_units_21 = dict()
      unit_map12 = dict()
      unit_map21 = dict()
  
      unit1_ids = sorting1.get_unit_ids()
      unit2_ids = sorting2.get_unit_ids()
      N1 = len(unit1_ids)
      N2 = len(unit2_ids)
      
      # Compute events counts
      event_counts1 = np.zeros((N1)).astype(np.int64)
      for i1, u1 in enumerate(unit1_ids):
          times1 = sorting1.get_unit_spike_train(u1)
          event_counts1[i1] = len(times1)
          event_counts_1[u1] = len(times1)
      event_counts2 = np.zeros((N2)).astype(np.int64)
      for i2, u2 in enumerate(unit2_ids):
          times2 = sorting2.get_unit_spike_train(u2)
          event_counts2[i2] = len(times2)
          event_counts_2[u2] = len(times2)
  
      # Compute matching events
      matching_event_counts = np.zeros((N1, N2)).astype(np.int64)
      scores = np.zeros((N1, N2))
      for i1, u1 in enumerate(unit1_ids):
          times1 = sorting1.get_unit_spike_train(u1)
          for i2, u2 in enumerate(unit2_ids):
              times2 = sorting2.get_unit_spike_train(u2)
              num_matches = count_matching_events(times1, times2, delta=delta_tp)
              matching_event_counts[i1, i2] = num_matches
              scores[i1, i2] = compute_agreement_score(num_matches, event_counts1[i1], event_counts2[i2])
  
      # Find best matches for spiketrains 1
      for i1, u1 in enumerate(unit1_ids):
          scores0 = scores[i1, :]
          matching_event_counts_12[u1] = dict()
          if len(scores0)>0:
              if np.max(scores0) > 0:
                  inds0 = np.where(scores0 > 0)[0]
                  for i2 in inds0:
                      matching_event_counts_12[u1][unit2_ids[i2]] = matching_event_counts[i1, i2]
                  i2_best = np.argmax(scores0)
                  best_match_units_12[u1] = unit2_ids[i2_best]
              else:
                  best_match_units_12[u1] = -1
          else:
              best_match_units_12[u1] = -1
  
      # Find best matches for spiketrains 2
      for i2, u2 in enumerate(unit2_ids):
          scores0 = scores[:, i2]
          matching_event_counts_21[u2] = dict()
          if len(scores0)>0:
              if np.max(scores0) > 0:
                  inds0 = np.where(scores0 > 0)[0]
                  for i1 in inds0:
                      matching_event_counts_21[u2][unit1_ids[i1]] = matching_event_counts[i1, i2]
                  i1_best = np.argmax(scores0)
                  best_match_units_21[u2] = unit1_ids[i1_best]
              else:
                  best_match_units_21[u2] = -1
          else:
              best_match_units_21[u2] = -1
  
      # Assign best matches
      [inds1, inds2] = linear_sum_assignment(-scores)
      inds1 = list(inds1)
      inds2 = list(inds2)
      if len(unit2_ids)>0:
          k2 = np.max(unit2_ids) + 1
      else:
          k2 = 1
      for i1, u1 in enumerate(unit1_ids):
          if i1 in inds1:
              aa = inds1.index(i1)
              i2 = inds2[aa]
              u2 = unit2_ids[i2]
              # criteria on agreement_score
              num_matches = matching_event_counts_12[u1].get(u2, 0)
              num1 = event_counts_1[u1]
              num2 = event_counts_2[u2]
              agree_score = compute_agreement_score(num_matches, num1, num2)
              if agree_score > min_accuracy:
                  unit_map12[u1] = u2
              else:
                  unit_map12[u1] = -1
          else:
              # unit_map12[u1] = k2
              # k2 = k2+1
              unit_map12[u1] = -1
      if len(unit1_ids)>0:
          k1 = np.max(unit1_ids) + 1
      else:
          k1 = 1
      for i2, u2 in enumerate(unit2_ids):
          if i2 in inds2:
              aa = inds2.index(i2)
              i1 = inds1[aa]
              u1 = unit1_ids[i1]
              # criteria on agreement_score
              num_matches = matching_event_counts_12[u1].get(u2, 0)
              num1 = event_counts_1[u1]
              num2 = event_counts_2[u2]
              agree_score = compute_agreement_score(num_matches, num1, num2)
              if agree_score > min_accuracy:
                  unit_map21[u2] = u1
              else:
                  unit_map21[u2] = -1
          else:
              # unit_map21[u2] = k1
              # k1 = k1+1
              unit_map21[u2] = -1
      
      return (event_counts_1,  event_counts_2,
                  matching_event_counts_12, best_match_units_12,
                  matching_event_counts_21,  best_match_units_21, 
                  unit_map12,  unit_map21)