code: def export_onnx(args):
      assert args.config is not None, "Please set --config path/to/yml"
      cfg = Config(args.config)
      builder = SegBuilder(cfg)
      model = builder.model
      if args.model_path is not None:
          utils.load_entire_model(model, args.model_path)
          logger.info("Loaded trained params of model successfully")
  
      model.eval()
      if args.print_model:
          print(model)
  
      input_shape = [1, 3, args.height, args.width]
      print("input shape:", input_shape)
      input_data = np.random.random(input_shape).astype("float32")
      model_name = os.path.basename(args.config).split(".")[0]
  
      paddle_out = run_paddle(model, input_data)
      print("out shape:", paddle_out.shape)
      print("The paddle model has been predicted by PaddlePaddle.\n")
  
      input_spec = paddle.static.InputSpec(input_shape, "float32", "x")
      onnx_model_path = os.path.join(
          args.save_dir, model_name + "_model"
      )
      paddle.onnx.export(
          model,
          onnx_model_path,
          input_spec=[input_spec],
          opset_version=11,
      )
      print("Completed export onnx model.\n")
  
      onnx_model_path = onnx_model_path + ".onnx"
      onnx_out = check_and_run_onnx(onnx_model_path, input_data)
      assert onnx_out.shape == paddle_out.shape
      np.testing.assert_allclose(
          onnx_out, paddle_out, rtol=0, atol=1e-03
      )
      print("The paddle and onnx models have the same outputs.\n")
  
file_path: PaddleSeg/contrib/QualityInspector/tools/seg/model/export_onnx.py
imports: import argparse
  import codecs
  import os
  import sys
  import time
  import numpy
  from tqdm import tqdm
  import paddle
  import onnx
  import onnxruntime
  from paddleseg.cvlibs import Config, SegBuilder
  from paddleseg.utils import logger, utils
label_desc: Use image node_id 4 for calling a global function with example usage: export_onnx(args) without return types