code: def _main():
      parser = argparse.ArgumentParser()
  
      parser.add_argument(
          "-n",
          "--network",
          type=_text_type,
          help="Model Type",
          required=True,
          choices=_default_model_info.keys(),
      )
  
      parser.add_argument(
          "-i",
          "--image",
          default=None,
          type=_text_type,
          help="Test Image Path",
      )
  
      parser.add_argument(
          "-o",
          "--output_dir",
          default="./",
          type=_text_type,
          help="Tensorflow Checkpoint file name",
      )
  
      args = parser.parse_args()
  
      if not download_file(
          _default_model_info[args.network]["symbol"],
          directory=args.output_dir,
      ):
          return -1
  
      if not download_file(
          _default_model_info[args.network]["params"],
          directory=args.output_dir,
      ):
          return -1
  
      print("Model {} saved.".format(args.network))
  
      file_name = _default_model_info[args.network]["params"].split(
          "/"
      )[-1]
      prefix, epoch_num = file_name[:-7].rsplit("-", 1)
  
      sym, arg_params, aux_params = mx.model.load_checkpoint(
          args.output_dir + prefix, int(epoch_num)
      )
      model = mx.mod.Module(symbol=sym)
      model.bind(
          for_training=False,
          data_shapes=[
              (
                  "data",
                  (
                      1,
                      3,
                      _default_model_info[args.network]["image_size"],
                      _default_model_info[args.network]["image_size"],
                  ),
              )
          ],
      )
      model.set_params(
          arg_params, aux_params, allow_missing=True, allow_extra=True
      )
  
      if args.image:
          import numpy as np
  
          # need to be updated
          network = _search_preprocess_key(args.network)
  
          func = TestKit.preprocess_func["mxnet"][network]
          img = func(args.image)
          img = np.swapaxes(img, 0, 2)
          img = np.swapaxes(img, 1, 2)
          img = np.expand_dims(img, axis=0)
  
          model.forward(Batch([mx.nd.array(img)]))
          predict = model.get_outputs()[0].asnumpy()
          predict = np.squeeze(predict)
          top_indices = predict.argsort()[-5:][::-1]
          result = [(i, predict[i]) for i in top_indices]
          print(result)
  
      return 0
  
file_path: MMdnn/mmdnn/conversion/examples/mxnet/extract_model.py
imports: import argparse
  from six import text_type
  import mxnet
  from mmdnn.conversion.examples.imagenet_test import TestKit
  from mmdnn.conversion.common.utils import download_file
  from collections import namedtuple
label_desc: Use image node_id 2 for calling a global function with example usage: _main() and returns: int, unknown, unknown