code: def test_accuracy_calculator_large_k(self):
      np.random.seed(493)
      for ecfss in [False, True]:
          for max_k in [None, 98, "max_bin_count"]:
              for num_embeddings in [1000, 2100]:
                  for num_classes in [2, 11, 103]:
                      # make random features
                      encs = np.random.rand(num_embeddings, 5).astype(
                          np.float32
                      )
                      # and random labels of 100 classes
                      labels = np.random.randint(
                          0, num_classes, size=(num_embeddings,)
                      )
  
                      (
                          correct_p1,
                          correct_map,
                          correct_mapr,
                      ) = self.evaluate(encs, labels, max_k, ecfss)
  
                      # use Musgrave's library
                      if max_k is None:
                          k = len(encs) - 1 if ecfss else len(encs)
                          accs = [
                              accuracy_calculator.AccuracyCalculator(
                                  device=TEST_DEVICE
                              ),
                              accuracy_calculator.AccuracyCalculator(
                                  k=k, device=TEST_DEVICE
                              ),
                          ]
                      else:
                          accs = [
                              accuracy_calculator.AccuracyCalculator(
                                  k=max_k, device=TEST_DEVICE
                              )
                          ]
  
                      for acc in accs:
                          d = acc.get_accuracy(
                              encs,
                              labels,
                              encs,
                              labels,
                              ecfss,
                              include=(
                                  "mean_average_precision",
                                  "mean_average_precision_at_r",
                                  "precision_at_1",
                              ),
                          )
  
                          self.assertAlmostEqual(
                              correct_p1, d["precision_at_1"], places=5
                          )
                          self.assertAlmostEqual(
                              correct_map,
                              d["mean_average_precision"],
                              places=5,
                          )
                          self.assertAlmostEqual(
                              correct_mapr,
                              d["mean_average_precision_at_r"],
                              places=5,
                          )
  
file_path: pytorch-metric-learning/tests/utils/test_calculate_accuracies_large_k.py
imports: import unittest
  import numpy
  import torch
  from pytorch_metric_learning.utils import accuracy_calculator, inference
  from ..None import TEST_DEVICE
label_desc: Use image node_id 1 for calling the TestCalculateAccuraciesLargeK obj's underlying member method code with example usage: obj.test_accuracy_calculator_large_k() without return types