code: def get_label_match_counts(
      query_labels, reference_labels, label_comparison_fn
  ):
      unique_query_labels = get_unique_labels(query_labels)
      if label_comparison_fn is EQUALITY:
          comparison = unique_query_labels[:, None] == reference_labels
          match_counts = torch.sum(
              c_f.torch_all_from_dim_to_end(comparison, 2), dim=1
          )
      else:
          # Labels are compared with a custom function.
          # They might be non-categorical or multidimensional labels.
          match_counts = torch.empty(
              len(unique_query_labels),
              dtype=torch.long,
              device=query_labels.device,
          )
          for ix_a in range(len(unique_query_labels)):
              label_a = unique_query_labels[ix_a : ix_a + 1]
              match_counts[ix_a] = torch.sum(
                  label_comparison_fn(label_a, reference_labels)
              )
  
      return (unique_query_labels, match_counts)
  
imports: import torch
  from sklearn.metrics import adjusted_mutual_info_score, normalized_mutual_info_score
  from .None import common_functions
  from .inference import FaissKMeans, FaissKNN
label_desc: Use image node_id 8 for calling a global function with example usage: get_label_match_counts(query_labels, reference_labels, label_comparison_fn) and returns: unique_query_labels,  match_counts