code: def test_mean_ap() -> None:
      # Numerical test
      distance_matrix = torch.tensor(
          [
              [
                  0.0,
                  1.0,
                  0.5,
                  1.75,
              ],  # id = 100, PRs = [(1/1,1/2), (2/2, 2/2)], ap = 1.0
              [
                  1.0,
                  0.0,
                  1.5,
                  0.75,
              ],  # id = 100, PRs = [(0/1,0/2), (1/2, 1/2), (2/3, 2/2)], ap = 1/3+1/4 = 7/12
              [
                  0.5,
                  1.5,
                  0.0,
                  2.75,
              ],  # id = 100, PRs = [(1/1,1/2), (2/2, 2/2)], ap = 1.0
              [
                  1.75,
                  0.75,
                  2.75,
                  0.0,
              ],  # id = 101, This query does not have any match -> excluded from mAP calculation.
          ]
      )
      query_ids = torch.tensor([100, 100, 100, 101])
      meanap = mean_ap(distance_matrix, query_ids)
      np.testing.assert_almost_equal(
          meanap, (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 4 for calling a global function with example usage: test_mean_ap() without return types