code: def convert_net(net_name, conf, enable_micro):
      option = cvt.ConverterOption()
      option.name = net_name
      option.order = conf.get(ModelKeys.order, 0)
      if ModelKeys.quantize_stat in conf:
          option.quantize_stat = conf[ModelKeys.quantize_stat]
      else:
          option.quantize_stat = False
  
      if ModelKeys.graph_optimize_options in conf:
          option.transformer_option = conf[
              ModelKeys.graph_optimize_options
          ]
      if ModelKeys.winograd in conf:
          option.winograd = conf[ModelKeys.winograd]
      if ModelKeys.quantize in conf:
          option.quantize = conf[ModelKeys.quantize]
      if ModelKeys.quantize_schema in conf:
          option.quantize_schema = conf[ModelKeys.quantize_schema]
      if ModelKeys.quantize_large_weights in conf:
          option.quantize_large_weights = conf[
              ModelKeys.quantize_large_weights
          ]
      if ModelKeys.quantize_range_file in conf:
          option.quantize_range_file = conf[
              ModelKeys.quantize_range_file
          ]
      if ModelKeys.change_concat_ranges in conf:
          option.change_concat_ranges = conf[
              ModelKeys.change_concat_ranges
          ]
      if ModelKeys.cl_mem_type in conf:
          option.cl_mem_type = conf[ModelKeys.cl_mem_type]
      if ModelKeys.platform in conf:
          option.platform = conf[ModelKeys.platform]
      if ModelKeys.runtime in conf:
          option.device = conf[ModelKeys.runtime]
          if option.device == DeviceType.CPU_GPU:
              # when convert, cpu and gpu share the same model
              option.device = DeviceType.CPU
          # we don't need `value`, but to be consistent with legacy code
          # used by `base_converter`
          option.device = option.device.value
  
      if option.quantize_stat:
          option.quantize = False
  
      option.enable_micro = enable_micro
      option.data_type = conf[ModelKeys.data_type]
  
      for i in range(len(conf[ModelKeys.input_tensors])):
          input_node = cvt.NodeInfo()
          input_node.name = conf[ModelKeys.input_tensors][i]
          if ModelKeys.input_aliases in conf:
              input_node.alias = conf[ModelKeys.input_aliases][i]
          else:
              input_node.alias = input_node.name
          input_node.shape = conf[ModelKeys.input_shapes][i]
          input_node.data_type = conf[ModelKeys.input_data_types][i]
          input_node.data_format = conf[ModelKeys.input_data_formats][i]
          if (
              input_node.data_format == DataFormat.NCHW
              and len(input_node.shape) == 4
          ):
              input_node.shape = transpose_shape(
                  input_node.shape, [0, 2, 3, 1]
              )
              input_node.data_format = DataFormat.NHWC
          input_node.range = conf[ModelKeys.input_ranges][i]
          option.add_input_node(input_node)
  
      for i in range(len(conf[ModelKeys.output_tensors])):
          output_node = cvt.NodeInfo()
          output_node.name = conf[ModelKeys.output_tensors][i]
          if ModelKeys.output_aliases in conf:
              output_node.alias = conf[ModelKeys.output_aliases][i]
          else:
              output_node.alias = output_node.name
          output_node.shape = conf[ModelKeys.output_shapes][i]
          output_node.data_type = conf[ModelKeys.output_data_types][i]
          output_node.data_format = conf[ModelKeys.output_data_formats][
              i
          ]
          if (
              output_node.data_format == DataFormat.NCHW
              and len(output_node.shape) == 4
          ):
              output_node.shape = transpose_shape(
                  output_node.shape, [0, 2, 3, 1]
              )
              output_node.data_format = DataFormat.NHWC
          option.add_output_node(output_node)
  
      if ModelKeys.check_tensors in conf:
          for i in range(len(conf[ModelKeys.check_tensors])):
              check_node = cvt.NodeInfo()
              check_node.name = conf[ModelKeys.check_tensors][i]
              check_node.shape = conf[ModelKeys.check_shapes][i]
              option.add_check_node(check_node)
      else:
          option.check_nodes = option.output_nodes
  
      option.build()
  
      print("Transform model to one that can better run on device")
      platform = conf[ModelKeys.platform]
      if platform == Platform.TENSORFLOW:
          from transform import tensorflow_converter
  
          converter = tensorflow_converter.TensorflowConverter(
              option, conf["model_file_path"]
          )
      elif platform == Platform.CAFFE:
          from transform import caffe_converter
  
          converter = caffe_converter.CaffeConverter(
              option, conf["model_file_path"], conf["weight_file_path"]
          )
      elif platform == Platform.ONNX:
          from transform import onnx_converter
  
          converter = onnx_converter.OnnxConverter(
              option, conf["model_file_path"]
          )
      elif platform == Platform.MEGENGINE:
          from transform import megengine_converter
  
          converter = megengine_converter.MegengineConverter(
              option, conf["model_file_path"]
          )
      elif platform == Platform.KERAS:
          from transform import keras_converter
  
          converter = keras_converter.KerasConverter(
              option, conf["model_file_path"]
          )
      elif platform == Platform.PYTORCH:
          from transform import pytorch_converter
  
          converter = pytorch_converter.PytorchConverter(
              option, conf["model_file_path"]
          )
      else:
          mace_check(
              False, "Mace do not support platorm %s yet." % platform
          )
  
      # Converter needs to pass some info to transformer by converter_info.
      output_graph_def, converter_info = converter.run()
      mace_transformer = transformer.Transformer(
          option, output_graph_def, converter_info
      )
      (
          output_graph_def,
          quantize_activation_info,
      ) = mace_transformer.run()
  
      runtime = conf[ModelKeys.runtime]
      if runtime in [DeviceType.HEXAGON, DeviceType.HTA]:
          from transform import hexagon_converter
  
          converter = hexagon_converter.HexagonConverter(
              option, output_graph_def, quantize_activation_info
          )
          output_graph_def = converter.run()
      elif runtime == DeviceType.APU:
          mace_check(
              platform == Platform.TENSORFLOW,
              "apu only support model from tensorflow",
          )
          from transform import apu_converter
  
          converter = apu_converter.ApuConverter(
              option, output_graph_def, quantize_activation_info
          )
          output_graph_def = converter.run()
  
      return output_graph_def
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import copy
  import sys
  from micro_converter import MicroConverter
  from py_proto import mace_pb2
  from utils import config_parser
  from utils.config_parser import DataFormat
  from utils.config_parser import DeviceType
  from utils.config_parser import Platform
  from utils import util
  from utils.util import mace_check
  from utils.config_parser import normalize_model_config
  from utils.config_parser import ModelKeys
  from utils.convert_util import merge_params
  from transform import base_converter
  from transform import transformer
  from visualize import visualize_model
label_desc: Use image node_id 5 for calling a global function with example usage: convert_net(net_name, conf, enable_micro) and returns: output_graph_def