class_docstr: OnnxModule is as a replacement of torch.nn.Module for running forward pass with onnxruntime.
  
  The module can be generated with MultiModalPredictor.export_tensorrt(),
  so that we can predict with TensorRT by simply replacing predictor._model with OnnxModule.
docstr: Parameters
  ----------
  onnx_path : str or bytes
      The file path (or bytes) of the onnx model that need to be executed in onnxruntime.
  providers : dict or str, default=None
      A list of execution providers for model prediction in onnxruntime.
code: def __init__(
      self,
      onnx_path: Union[str, bytes],
      providers: Optional[Union[dict, List[str]]] = None,
  ):
      """
      Parameters
      ----------
      onnx_path : str or bytes
          The file path (or bytes) of the onnx model that need to be executed in onnxruntime.
      providers : dict or str, default=None
          A list of execution providers for model prediction in onnxruntime.
      """
      import onnx
      import onnxruntime as ort
  
      if isinstance(onnx_path, bytes):
          onnx_model = onnx.load_model_from_string(onnx_path)
      else:
          if not os.path.exists(onnx_path):
              raise FileNotFoundError(
                  f"failed to located onnx file at {onnx_path}"
              )
  
          logger.info(
              "Loading ONNX file from path {}...".format(onnx_path)
          )
          onnx_model = onnx.load(onnx_path)
  
      if providers is None:
          if isinstance(onnx_path, str):
              dirname = os.path.dirname(os.path.abspath(onnx_path))
              cache_path = os.path.join(dirname, "model_trt")
          else:
              cache_path = None
          providers = [
              (
                  "TensorrtExecutionProvider",
                  {
                      "device_id": 0,
                      "trt_max_workspace_size": 2147483648,
                      "trt_fp16_enable": True,
                      "trt_engine_cache_path": cache_path,
                      "trt_engine_cache_enable": True,
                  },
              ),
              (
                  "CUDAExecutionProvider",
                  {
                      "device_id": 0,
                      "arena_extend_strategy": "kNextPowerOfTwo",
                      "gpu_mem_limit": 2 * 1024 * 1024 * 1024,
                      "cudnn_conv_algo_search": "EXHAUSTIVE",
                      "do_copy_in_default_stream": True,
                  },
              ),
              ("CPUExecutionProvider", {}),
          ]
  
      if (
          len(providers) == 1
          and get_provider_name(providers[0])
          == "TensorrtExecutionProvider"
      ):
          if not tensorrt_imported:
              raise ImportError(
                  "tensorrt package is not installed. The package can be install via `pip install tensorrt`."
              )
  
      self.sess = ort.InferenceSession(
          onnx_model.SerializeToString(), providers=providers
      )
  
      if (
          get_provider_name(providers[0]) == "TensorrtExecutionProvider"
          and tensorrt_imported
      ):
          assert (
              "TensorrtExecutionProvider" in self.sess.get_providers()
          ), (
              f"unexpected TensorRT compilation failure: TensorrtExecutionProvider not in providers ({self.sess.get_providers()}). "
              "Make sure onnxruntime package gets lazy imported everywhere."
          )
  
      inputs = self.sess.get_inputs()
      outputs = self.sess.get_outputs()
      self.input_names = [i.name for i in inputs]
      self.output_names = [i.name for i in outputs]
  
file_path: autogluon/multimodal/src/autogluon/multimodal/utils/onnx.py
imports: import logging
  import os
  from typing import Dict, List, Optional, Tuple, Union
  from torch import tensor
  from ..constants import AUTOMM, FEATURE_EXTRACTION, MULTICLASS
label_desc: Use image node_id 1 to create a new OnnxModule object from inherited base classes: object with example: obj = OnnxModule(onnx_path, providers)