code: def correct_mean_average_precision_at_r(
      self, ref_includes_query, avg_of_avgs, return_per_class
  ):
      if not ref_includes_query:
          acc0 = (1.0 / 2 + 2.0 / 3) / 3
          acc1 = (1 + 2.0 / 3) / 3
          acc2 = (1.0 / 5) / 5
          acc3 = (1 + 2.0 / 3) / 4
          acc4 = (1.0 / 3) / 5
          acc5 = 0
      else:
          acc0 = 1
          acc1 = (1.0 / 2) / 2
          acc2 = (1.0 / 4) / 4
          acc3 = (1.0 / 2) / 3
          acc4 = (1.0 / 2) / 4
          acc5 = 0
      accs = [acc5, (acc0 + acc1) / 2, acc2, acc3, acc4]
      if avg_of_avgs:
          return np.mean(accs)
      elif return_per_class:
          return accs
      else:
          return np.mean([acc0, acc1, acc2, acc3, acc4, acc5])
  
imports: import itertools
  import logging
  import unittest
  import numpy
  import torch
  from pytorch_metric_learning.distances import LpDistance
  from pytorch_metric_learning.utils import accuracy_calculator
  from pytorch_metric_learning.utils.common_functions import LOGGER
  from pytorch_metric_learning.utils.inference import CustomKNN, FaissKMeans, FaissKNN
  from ..None import TEST_DEVICE
label_desc: Use image node_id 4 for calling the TestCalculateAccuracies obj's underlying member method code with example usage: obj.correct_mean_average_precision_at_r(ref_includes_query, avg_of_avgs, return_per_class) and returns: np, accs, np