code: def test_retrieval_cmc() -> None:
      opts = argparse.Namespace()
      setattr(opts, "stats.metrics.retrieval_cmc.distance_metric", "l2")
      setattr(opts, "stats.metrics.retrieval_cmc.subset_fraction", 1.0)
      setattr(opts, "stats.metrics.retrieval_cmc.k", 2)
      cmc_eval = RetrievalCMC(
          # device=torch.device("cpu"),
          opts=opts,
          is_distributed=False,
          compute_map=True,
      )
  
      embeddings = torch.tensor(
          [
              [[0.0, 0.0], [0.0, 1.0]],
              [[0.0, -0.5], [0.0, 1.75]],
          ]
      )
      labels = torch.tensor([[100, 100], [100, 101]])
  
      cmc_eval.reset()
      for embedding, label in zip(embeddings, labels):
          cmc_eval.update(embedding, label)
  
      # outputs are reported in percentages
      cmc_metrics = cmc_eval.compute()
  
      np.testing.assert_almost_equal(cmc_metrics["top1"], 50)
      np.testing.assert_almost_equal(cmc_metrics["top2"], 75)
      np.testing.assert_almost_equal(
          cmc_metrics["mAP"], 100 * (1.0 + 7.0 / 12.0 + 1.0) / 3.0
      )
  
file_path: ml-cvnets/tests/metrics/test_retrieval_cmc_metrics.py
imports: import argparse
  import numpy
  import pytest
  import torch
  from metrics.retrieval_cmc import RetrievalCMC, cmc_calculation, cosine_distance_matrix, l2_distance_matrix, mean_ap
label_desc: Use image node_id 5 for calling a global function with example usage: test_retrieval_cmc() without return types