code: def test(ctx):
      metric = mx.gluon.metric.Accuracy()
      for data, label in val_data:
          data = data.to_device(ctx)
          label = label.to_device(ctx)
          output = net(data)
          metric.update([label], [output])
  
      return metric.get()
  
file_path: mxnet/example/gluon/mnist/mnist.py
imports: from __future__ import print_function
  import argparse
  import logging
  import numpy
  import mxnet
  from mxnet import gluon, autograd
  from mxnet.gluon import nn
label_desc: Use image node_id 2 for calling a global function with example usage: test(ctx) and returns: metric