code: def main(FLAGS):
      assert os.path.exists(FLAGS.onnx_file)
      onnx_model = onnx.load(FLAGS.onnx_file)
      graph = onnx_graphsurgeon.import_onnx(onnx_model)
      graph.toposort()
      graph.fold_constants()
      graph.cleanup()
  
      num_anchors = graph.outputs[1].shape[2]
      num_classes = graph.outputs[1].shape[1]
      scores = onnx_graphsurgeon.Variable(
          name="scores",
          shape=[-1, num_anchors, num_classes],
          dtype=np.float32,
      )
      graph.layer(
          op="Transpose",
          name="lastTranspose",
          inputs=[graph.outputs[1]],
          outputs=[scores],
          attrs=OrderedDict(perm=[0, 2, 1]),
      )
  
      attrs = OrderedDict(
          plugin_version="1",
          background_class=-1,
          max_output_boxes=FLAGS.topk_all,
          score_threshold=FLAGS.conf_thres,
          iou_threshold=FLAGS.iou_thres,
          score_activation=False,
          box_coding=0,
      )
      outputs = [
          onnx_graphsurgeon.Variable("num_dets", np.int32, [-1, 1]),
          onnx_graphsurgeon.Variable(
              "det_boxes", np.float32, [-1, FLAGS.topk_all, 4]
          ),
          onnx_graphsurgeon.Variable(
              "det_scores", np.float32, [-1, FLAGS.topk_all]
          ),
          onnx_graphsurgeon.Variable(
              "det_classes", np.int32, [-1, FLAGS.topk_all]
          ),
      ]
      graph.layer(
          op="EfficientNMS_TRT",
          name="batched_nms",
          inputs=[graph.outputs[0], scores],
          outputs=outputs,
          attrs=attrs,
      )
      graph.outputs = outputs
      graph.cleanup().toposort()
      onnx.save(onnx_graphsurgeon.export_onnx(graph), FLAGS.onnx_file)
      print(f"The modified onnx model is saved in {FLAGS.onnx_file}")
  
imports: import argparse
  import os
  import onnx
  import onnx_graphsurgeon
  import numpy
  from collections import OrderedDict
  from paddle2onnx.command import program2onnx
label_desc: Use image node_id 1 for calling a global function with example usage: main(FLAGS) without return types