code: def _test_accuracy_calculator_and_faiss(self, use_numpy):
      custom_knn = CustomKNN(
          LpDistance(normalize_embeddings=False, power=2)
      )
      custom_knn2 = CustomKNN(
          LpDistance(normalize_embeddings=False, power=2), batch_size=3
      )
      for knn_func in [None, custom_knn, custom_knn2]:
          AC = accuracy_calculator.AccuracyCalculator(
              device=TEST_DEVICE, knn_func=knn_func
          )
          if use_numpy:
              query = np.arange(10)[:, None]
              reference = np.arange(10)[:, None]
              query_labels = np.arange(10)
              reference_labels = np.arange(10)
          else:
              query = torch.arange(10, device=TEST_DEVICE).unsqueeze(1)
              reference = torch.arange(
                  10, device=TEST_DEVICE
              ).unsqueeze(1)
              query_labels = torch.arange(10, device=TEST_DEVICE)
              reference_labels = torch.arange(10, device=TEST_DEVICE)
          acc = AC.get_accuracy(
              query, query_labels, reference, reference_labels, False
          )
          self.assertTrue(isclose(acc["precision_at_1"], 1))
          self.assertTrue(isclose(acc["r_precision"], 1))
          self.assertTrue(
              isclose(acc["mean_average_precision_at_r"], 1)
          )
          self.assertTrue(isclose(acc["mean_average_precision"], 1))
  
          if use_numpy:
              reference = (np.arange(20) / 2.0)[:, None]
              reference = np.concatenate(
                  [reference[::2], reference[1::2]], axis=0
              )
              reference_labels = np.zeros(20)
              reference_labels[: len(query)] = query_labels
              reference_labels[len(query) :] = np.ones(10)
          else:
              reference = (
                  torch.arange(20, device=TEST_DEVICE) / 2.0
              ).unsqueeze(1)
              reference = torch.cat(
                  [reference[::2], reference[1::2]], dim=0
              )
              reference_labels = torch.zeros(20, device=TEST_DEVICE)
              reference_labels[: len(query)] = query_labels
              reference_labels[len(query) :] = torch.ones(10)
          acc = AC.get_accuracy(
              query, query_labels, reference, reference_labels, True
          )
          self.assertTrue(isclose(acc["precision_at_1"], 1))
          self.assertTrue(isclose(acc["r_precision"], 0.5))
          self.assertTrue(
              isclose(
                  acc["mean_average_precision_at_r"],
                  (1 + 2.0 / 2 + 3.0 / 5 + 4.0 / 7 + 5.0 / 9) / 10,
              )
          )
          self.assertTrue(
              isclose(
                  acc["mean_average_precision"],
                  (
                      1
                      + 2.0 / 2
                      + 3.0 / 5
                      + 4.0 / 7
                      + 5.0 / 9
                      + 6.0 / 11
                      + 7.0 / 13
                      + 8.0 / 15
                      + 9.0 / 17
                      + 10.0 / 19
                  )
                  / 10,
              )
          )
  
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 2 for calling the TestCalculateAccuraciesAndFaiss obj's underlying member method code with example usage: obj._test_accuracy_calculator_and_faiss(use_numpy) without return types