code: def test_cmc_calculation() -> None:
      # Make sure input arrays are not modified
      distance_matrix = torch.zeros(10, 10)
      query_ids = torch.randint(0, 5, (10,))
      _, _ = cmc_calculation(distance_matrix, query_ids, 5)
      np.testing.assert_equal(distance_matrix.numpy(), 0)
  
      # Perfect match case
      distance_matrix = torch.tensor(
          [
              [0.0, 1.0, 0.5, 2.0],  # id = 100
              [1.0, 0.0, 2.0, 0.3],  # id = 101
              [0.5, 2.0, 0.0, 3.0],  # id = 100
              [2.0, 0.3, 3.0, 0.0],  # id = 101
          ]
      )
      query_ids = torch.tensor([100, 101, 100, 101])
      top1, top3 = cmc_calculation(distance_matrix, query_ids, 3)
      assert top1 == top3 == pytest.approx(1.0, 0.001)
  
      # Another case
      distance_matrix = torch.tensor(
          [
              [0.0, 1.0, 0.5, 1.75],  # id = 100
              [1.0, 0.0, 1.5, 0.75],  # id = 100
              [0.5, 1.5, 0.0, 2.75],  # id = 100
              [1.75, 0.75, 2.75, 0.0],  # id = 101
          ]
      )
      query_ids = torch.tensor([100, 100, 100, 101])
      top1, top2 = cmc_calculation(distance_matrix, query_ids, 2)
      assert top1 == pytest.approx(0.5, 0.001)
      assert top2 == pytest.approx(0.75, 0.001)
  
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 3 for calling a global function with example usage: test_cmc_calculation() without return types