code: def r_precision(
      knn_labels,
      gt_labels,
      ref_includes_query,
      label_counts,
      avg_of_avgs,
      return_per_class,
      label_comparison_fn,
  ):
      relevance_mask, _ = get_relevance_mask(
          knn_labels.shape[:2],
          gt_labels,
          ref_includes_query,
          label_counts,
      )
      same_label = label_comparison_fn(gt_labels, knn_labels)
      matches_per_row = torch.sum(same_label * relevance_mask, dim=1)
      max_possible_matches_per_row = torch.sum(relevance_mask, dim=1)
      accuracy_per_sample = (
          matches_per_row.type(torch.float64)
          / max_possible_matches_per_row
      )
      return maybe_get_avg_of_avgs(
          accuracy_per_sample, 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 4 for calling a global function with example usage: r_precision(knn_labels, gt_labels, ref_includes_query, label_counts, avg_of_avgs, return_per_class, label_comparison_fn) and returns: maybe_get_avg_of_avgs