code: def test_onnx_trt_export(
      self, convert_precision, input_shape, dynamic_batch
  ):
      meta_file = os.path.join(
          os.path.dirname(__file__), "testing_data", "metadata.json"
      )
      config_file = os.path.join(
          os.path.dirname(__file__), "testing_data", "inference.json"
      )
      with tempfile.TemporaryDirectory() as tempdir:
          def_args = {
              "meta_file": "will be replaced by `meta_file` arg"
          }
          def_args_file = os.path.join(tempdir, "def_args.yaml")
  
          ckpt_file = os.path.join(tempdir, "model.pt")
          ts_file = os.path.join(
              tempdir, f"model_trt_{convert_precision}.ts"
          )
  
          parser = ConfigParser()
          parser.export_config_file(
              config=def_args, filepath=def_args_file
          )
          parser.read_config(config_file)
          net = parser.get_parsed_content("network_def")
          save_state(src=net, path=ckpt_file)
  
          cmd = [
              "python",
              "-m",
              "monai.bundle",
              "trt_export",
              "network_def",
              "--filepath",
              ts_file,
          ]
          cmd += [
              "--meta_file",
              meta_file,
              "--config_file",
              f"['{config_file}','{def_args_file}']",
              "--ckpt_file",
          ]
          cmd += [
              ckpt_file,
              "--args_file",
              def_args_file,
              "--precision",
              convert_precision,
          ]
          cmd += ["--use_onnx", "True"]
          if input_shape:
              cmd += ["--input_shape", str(input_shape)]
          if dynamic_batch:
              cmd += ["--dynamic_batch", str(dynamic_batch)]
          command_line_tests(cmd)
          self.assertTrue(os.path.exists(ts_file))
  
          _, metadata, extra_files = load_net_with_metadata(
              ts_file,
              more_extra_files=["inference.json", "def_args.json"],
          )
          self.assertTrue("schema" in metadata)
          self.assertTrue(
              "meta_file" in json.loads(extra_files["def_args.json"])
          )
          self.assertTrue(
              "network_def" in json.loads(extra_files["inference.json"])
          )
  
file_path: MONAI/tests/test_bundle_trt_export.py
imports: from __future__ import annotations
  import json
  import os
  import tempfile
  import unittest
  from parameterized import parameterized
  from monai.bundle import ConfigParser
  from monai.data import load_net_with_metadata
  from monai.networks import save_state
  from monai.utils import optional_import
  from tests.utils import command_line_tests, skip_if_no_cuda, skip_if_quick, skip_if_windows
label_desc: Use image node_id 4 for calling the TestTRTExport obj's underlying member method code with example usage: obj.test_onnx_trt_export(convert_precision, input_shape, dynamic_batch) without return types