code: def pred_eval(predictor, test_data, imdb, vis=False, thresh=1e-3):
      """
      wrapper for calculating offline validation for faster data analysis
      in this example, all threshold are set by hand
      :param predictor: Predictor
      :param test_data: data iterator, must be non-shuffle
      :param imdb: image database
      :param vis: controls visualization
      :param thresh: valid detection threshold
      :return:
      """
      assert vis or not test_data.shuffle
      data_names = [k[0] for k in test_data.provide_data]
  
      nms = py_nms_wrapper(config.TEST.NMS)
  
      # limit detections to max_per_image over all classes
      max_per_image = -1
  
      num_images = imdb.num_images
      # all detections are collected into:
      #    all_boxes[cls][image] = N x 5 array of detections in
      #    (x1, y1, x2, y2, score)
      all_boxes = [
          [[] for _ in range(num_images)]
          for _ in range(imdb.num_classes)
      ]
  
      i = 0
      t = time.time()
      for im_info, data_batch in test_data:
          t1 = time.time() - t
          t = time.time()
  
          scale = im_info[0, 2]
          scores, boxes, data_dict = im_detect(
              predictor, data_batch, data_names, scale
          )
  
          t2 = time.time() - t
          t = time.time()
  
          for j in range(1, imdb.num_classes):
              indexes = np.where(scores[:, j] > thresh)[0]
              cls_scores = scores[indexes, j, np.newaxis]
              cls_boxes = boxes[indexes, j * 4 : (j + 1) * 4]
              cls_dets = np.hstack((cls_boxes, cls_scores))
              keep = nms(cls_dets)
              all_boxes[j][i] = cls_dets[keep, :]
  
          if max_per_image > 0:
              image_scores = np.hstack(
                  [
                      all_boxes[j][i][:, -1]
                      for j in range(1, imdb.num_classes)
                  ]
              )
              if len(image_scores) > max_per_image:
                  image_thresh = np.sort(image_scores)[-max_per_image]
                  for j in range(1, imdb.num_classes):
                      keep = np.where(
                          all_boxes[j][i][:, -1] >= image_thresh
                      )[0]
                      all_boxes[j][i] = all_boxes[j][i][keep, :]
  
          if vis:
              boxes_this_image = [[]] + [
                  all_boxes[j][i] for j in range(1, imdb.num_classes)
              ]
              vis_all_detection(
                  data_dict["data"].asnumpy(),
                  boxes_this_image,
                  imdb.classes,
                  scale,
              )
  
          t3 = time.time() - t
          t = time.time()
          logger.info(
              "testing %d/%d data %.4fs net %.4fs post %.4fs"
              % (i, imdb.num_images, t1, t2, t3)
          )
          i += 1
  
      det_file = os.path.join(
          imdb.cache_path, imdb.name + "_detections.pkl"
      )
      with open(det_file, "wb") as f:
          pickle.dump(all_boxes, f, protocol=pickle.HIGHEST_PROTOCOL)
  
      imdb.evaluate_detections(all_boxes)
  
imports: from __future__ import print_function
  import os
  import sys
  import time
  import mxnet
  import numpy
  from builtins import range
  from mxnet.module import Module
  from .module import MutableModule
  from rcnn.logger import logger
  from rcnn.config import config
  from rcnn.io import image
  from rcnn.processing.bbox_transform import bbox_pred, clip_boxes
  from rcnn.processing.nms import py_nms_wrapper, cpu_nms_wrapper, gpu_nms_wrapper
  from rcnn.processing.bbox_transform import bbox_overlaps
label_desc: Use image node_id 7 for calling a global function with example usage: pred_eval(predictor, test_data, imdb, vis, thresh) without return types