code: def mean_reciprocal_rank(
      knn_labels,
      gt_labels,
      avg_of_avgs,
      return_per_class,
      label_comparison_fn,
  ):
      device = gt_labels.device
      is_same_label = label_comparison_fn(gt_labels, knn_labels)
  
      # find & remove caeses where it has 0 correct results
      sum_per_row = is_same_label.sum(-1)
      zero_remove_mask = sum_per_row > 0
      indices = torch.arange(
          is_same_label.shape[1], 0, -1, device=device
      )
      tmp = is_same_label * indices
      indices = torch.argmax(tmp, 1, keepdim=True) + 1.0
  
      indices[zero_remove_mask] = 1.0 / indices[zero_remove_mask]
      indices[~zero_remove_mask] = 0.0
  
      indices = indices.flatten()
  
      return maybe_get_avg_of_avgs(
          indices, gt_labels, avg_of_avgs, return_per_class
      )
  
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 6 for calling a global function with example usage: mean_reciprocal_rank(knn_labels, gt_labels, avg_of_avgs, return_per_class, label_comparison_fn) and returns: maybe_get_avg_of_avgs