code: def _main():
      parser = argparse.ArgumentParser()
  
      parser.add_argument(
          "-n",
          "--network",
          type=_text_type,
          help="Model Type",
          required=True,
          choices=MODEL_URL.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="Paddlepaddle parameters file name",
      )
  
      args = parser.parse_args()
  
      fn = download_file(
          MODEL_URL[args.network],
          local_fname=architecture + ".tar.gz",
          directory=args.output_dir,
      )
      if not fn:
          return -1
  
      DATA_DIM = (
          3 * IMG_SIZE * IMG_SIZE
      )  # Use 3 * 331 * 331 or 3 * 299 * 299 for Inception-ResNet-v2.
      CLASS_DIM = CLASS_DIMS[args.network]
  
      # refer to https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/tests/test_rnn_layer.py#L35
      reset_parser()
  
      # refer to https://github.com/PaddlePaddle/Paddle/issues/7403
      paddle.init(use_gpu=False, trainer_count=1)
  
      image = paddle.layer.data(
          name="image", type=paddle.data_type.dense_vector(DATA_DIM)
      )
      if "resnet" in architecture:
          from mmdnn.conversion.examples.paddle.models import resnet
  
          depth = int(architecture.strip("resnet"))
          out = resnet.resnet_imagenet(
              image, class_dim=CLASS_DIM, depth=depth
          )
      elif architecture == "vgg16":
          from mmdnn.conversion.examples.paddle.models import vgg
  
          out = vgg.vgg16(image, class_dim=CLASS_DIM)
      else:
          print("Not support for {} yet.", architecture)
          return None
  
      dump_v2_config(out, args.output_dir + architecture + ".bin")
  
      print(
          "Model {} is saved as {} and {}.".format(
              args.network, args.output_dir + architecture + ".bin", fn
          )
      )
  
      if args.image:
          import numpy as np
          from mmdnn.conversion.examples.imagenet_test import TestKit
  
          func = TestKit.preprocess_func["paddle"][args.network]
          img = func(args.image)
          img = np.transpose(img, (2, 0, 1))
          test_data = [(img.flatten(),)]
  
          with gzip.open(parameters_file, "r") as f:
              parameters = paddle.parameters.Parameters.from_tar(f)
  
          predict = paddle.infer(
              output_layer=out, parameters=parameters, input=test_data
          )
          predict = np.squeeze(predict)
          top_indices = predict.argsort()[-5:][::-1]
          result = [(i, predict[i]) for i in top_indices]
          print(result)
          print(np.sum(result))
  
      return 0
  
file_path: MMdnn/mmdnn/conversion/examples/paddle/extract_model.py
imports: import argparse
  import os
  from six import text_type
  from mmdnn.conversion.common.utils import download_file
  import paddle.v2
  import gzip
  from paddle.trainer_config_helpers.config_parser_utils import reset_parser
label_desc: Use image node_id 2 for calling a global function with example usage: _main() and returns: int, unknown, None