code: def compute_mAP(index, good_index, junk_index):
      ap = 0
      cmc = np.zeros(len(index))
      if good_index.size == 0:  # if empty
          cmc[0] = -1
          return ap, cmc
  
      # remove junk_index
      mask = np.in1d(index, junk_index, invert=True)
      index = index[mask]
  
      # find good_index index
      ngood = len(good_index)
      mask = np.in1d(index, good_index)
      rows_good = np.argwhere(mask == True)
      rows_good = rows_good.flatten()
  
      cmc[rows_good[0] :] = 1
      for i in range(ngood):
          d_recall = 1.0 / ngood
          precision = (i + 1) * 1.0 / (rows_good[i] + 1)
          if rows_good[i] != 0:
              old_precision = i * 1.0 / rows_good[i]
          else:
              old_precision = 1.0
          ap = ap + d_recall * (old_precision + precision) / 2
  
      return ap, cmc
  
file_path: gluon-cv/scripts/re-id/baseline/test.py
imports: from __future__ import print_function, division
  import mxnet
  import numpy
  from mxnet import gluon, nd
  from mxnet.gluon import nn
  from mxnet.gluon.data.vision import transforms
  from networks import resnet18, resnet34, resnet50
  import gluoncv
  from gluoncv.data.market1501.data_read import ImageTxtDataset
  import time, os, sys
  import scipy.io
  from os import path
label_desc: Use image node_id 6 for calling a global function with example usage: compute_mAP(index, good_index, junk_index) and returns: ap,  cmc, ap,  cmc