code: def test_quantization(
      model, args, test_data, size, num_class, pred_offset
  ):
      # output folder
      outdir = "outdir_int8"
      if not os.path.exists(outdir):
          os.makedirs(outdir)
      print(model)
      metric = gluoncv.utils.metrics.SegmentationMetric(num_class)
  
      tbar = tqdm(test_data)
      metric.reset()
      tic = time.time()
      for i, (batch, dsts) in enumerate(tbar):
          if args.eval:
              targets = mx.gluon.utils.split_and_load(
                  dsts, ctx_list=args.ctx, even_split=False
              )
              data = mx.gluon.utils.split_and_load(
                  batch,
                  ctx_list=args.ctx,
                  batch_axis=0,
                  even_split=False,
              )
              outputs = None
              for x in data:
                  output = model(x)
                  outputs = (
                      output
                      if outputs is None
                      else nd.concat(outputs, output, axis=0)
                  )
              metric.update(targets, outputs)
              pixAcc, mIoU = metric.get()
              tbar.set_description(
                  "pixAcc: %.4f, mIoU: %.4f" % (pixAcc, mIoU)
              )
          else:
              for data, impath in zip(batch, dsts):
                  data = data.as_in_context(args.ctx[0])
                  if len(data.shape) < 4:
                      data = nd.expand_dims(data, axis=0)
                  predict = model(data)[0]
                  predict = (
                      mx.nd.squeeze(mx.nd.argmax(predict, 1)).asnumpy()
                      + pred_offset
                  )
                  mask = get_color_pallete(predict, args.dataset)
                  outname = os.path.splitext(impath)[0] + ".png"
                  mask.save(os.path.join(outdir, outname))
      speed = size / (time.time() - tic)
      print(
          "Inference speed with batchsize %d is %.2f img/sec"
          % (args.batch_size, speed)
      )
  
imports: import os
  import logging
  from tqdm import tqdm
  import numpy
  import argparse
  import time
  import sys
  import mxnet
  from mxnet import gluon, ndarray
  from mxnet.gluon.data.vision import transforms
  from mxnet.contrib.quantization import *
  import gluoncv
  from gluoncv.model_zoo.segbase import *
  from gluoncv.model_zoo import get_model
  from gluoncv.data import get_segmentation_dataset, ms_batchify_fn
  from gluoncv.utils.viz import get_color_pallete
  from gluoncv.utils.parallel import *
label_desc: Use image node_id 3 for calling a global function with example usage: test_quantization(model, args, test_data, size, num_class, pred_offset) without return types