code: def validate(net, val_data, ctx, classes, size, metric):
      """Test on validation dataset."""
      net.collect_params().reset_ctx(ctx)
      metric.reset()
      with tqdm(total=size) as pbar:
          start = time.time()
          for ib, batch in enumerate(val_data):
              data = gluon.utils.split_and_load(
                  batch[0], ctx_list=ctx, batch_axis=0, even_split=False
              )
              label = gluon.utils.split_and_load(
                  batch[1], ctx_list=ctx, batch_axis=0, even_split=False
              )
              det_bboxes = []
              det_ids = []
              det_scores = []
              gt_bboxes = []
              gt_ids = []
              gt_difficults = []
              for x, y in zip(data, label):
                  ids, scores, bboxes = net(x)
                  det_ids.append(ids)
                  det_scores.append(scores)
                  # clip to image size
                  det_bboxes.append(bboxes.clip(0, batch[0].shape[2]))
                  # split ground truths
                  gt_ids.append(y.slice_axis(axis=-1, begin=4, end=5))
                  gt_bboxes.append(
                      y.slice_axis(axis=-1, begin=0, end=4)
                  )
                  gt_difficults.append(
                      y.slice_axis(axis=-1, begin=5, end=6)
                      if y.shape[-1] > 5
                      else None
                  )
  
              metric.update(
                  det_bboxes,
                  det_ids,
                  det_scores,
                  gt_bboxes,
                  gt_ids,
                  gt_difficults,
              )
              pbar.update(batch[0].shape[0])
          end = time.time()
          speed = size / (end - start)
          print("Throughput is %f img/sec." % speed)
      return metric.get()
  
imports: from __future__ import division
  from __future__ import print_function
  import argparse
  import logging
  import time
  import sys
  import numpy
  import mxnet
  from tqdm import tqdm
  from mxnet import nd
  from mxnet import gluon
  import gluoncv
  from gluoncv import data
  from gluoncv.data.batchify import Tuple, Stack, Pad
  from gluoncv.data.transforms.presets.ssd import SSDDefaultValTransform
  from gluoncv.utils.metrics.voc_detection import VOC07MApMetric
  from gluoncv.utils.metrics.coco_detection import COCODetectionMetric
  from mxnet.contrib.quantization import *
label_desc: Use image node_id 5 for calling a global function with example usage: validate(net, val_data, ctx, classes, size, metric) and returns: metric