code: def test(model, args, input_transform):
      # DO NOT modify!!! Only support batch_size=ngus
      batch_size = args.ngpus
  
      # output folder
      outdir = "outdir"
      if not os.path.exists(outdir):
          os.makedirs(outdir)
  
      # get dataset
      if args.eval:
          testset = get_segmentation_dataset(
              args.dataset,
              split="val",
              mode="testval",
              transform=input_transform,
          )
      else:
          testset = get_segmentation_dataset(
              args.dataset,
              split="test",
              mode="test",
              transform=input_transform,
          )
  
      if "icnet" or "fastscnn" in args.model:
          test_data = gluon.data.DataLoader(
              testset,
              batch_size,
              shuffle=False,
              last_batch="rollover",
              num_workers=args.workers,
          )
      else:
          test_data = gluon.data.DataLoader(
              testset,
              batch_size,
              shuffle=False,
              last_batch="rollover",
              batchify_fn=ms_batchify_fn,
              num_workers=args.workers,
          )
      print(model)
  
      if "icnet" or "fastscnn" in args.model:
          evaluator = DataParallelModel(
              SegEvalModel(model, use_predict=True), ctx_list=args.ctx
          )
      else:
          evaluator = MultiEvalModel(
              model, testset.num_class, ctx_list=args.ctx
          )
  
      metric = gluoncv.utils.metrics.SegmentationMetric(
          testset.num_class
      )
  
      if "icnet" or "fastscnn" in args.model:
          tbar = tqdm(test_data)
          t_gpu = 0
          num = 0
          for i, (data, dsts) in enumerate(tbar):
              tic = time.time()
              outputs = evaluator(data.astype("float32", copy=False))
              # outputs = evaluator(data.astype('float32', copy=False))
              t_gpu += time.time() - tic
              num += 1
  
              outputs = [x[0] for x in outputs]
              targets = mx.gluon.utils.split_and_load(
                  dsts, ctx_list=args.ctx, even_split=False
              )
              metric.update(targets, outputs)
  
              pixAcc, mIoU = metric.get()
              gpu_time = t_gpu / num
              tbar.set_description(
                  "pixAcc: %.4f, mIoU: %.4f, t_gpu: %.2fms"
                  % (pixAcc, mIoU, gpu_time * 1000)
              )
      else:
          tbar = tqdm(test_data)
          for i, (data, dsts) in enumerate(tbar):
              if args.eval:
                  predicts = [
                      pred[0]
                      for pred in evaluator.parallel_forward(data)
                  ]
                  targets = [
                      target.as_in_context(predicts[0].context)
                      for target in dsts
                  ]
                  metric.update(targets, predicts)
                  pixAcc, mIoU = metric.get()
                  tbar.set_description(
                      "pixAcc: %.4f, mIoU: %.4f" % (pixAcc, mIoU)
                  )
              else:
                  im_paths = dsts
                  predicts = evaluator.parallel_forward(data)
                  for predict, impath in zip(predicts, im_paths):
                      predict = (
                          mx.nd.squeeze(
                              mx.nd.argmax(predict[0], 1)
                          ).asnumpy()
                          + testset.pred_offset
                      )
                      mask = get_color_pallete(predict, args.dataset)
                      outname = os.path.splitext(impath)[0] + ".png"
                      mask.save(os.path.join(outdir, outname))
  
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 2 for calling a global function with example usage: test(model, args, input_transform) without return types