code: def test_onnx_tensorrt():
      with TemporaryDirectory() as tmp_dir:
          model = models.resnet18()
          input_data = [
              ((torch.randn(1, 3, 256, 256),), 0) for i in range(100)
          ]
          model_path = torch_to_onnx(model, input_data, tmp_dir)
  
          input_data = [
              ((np.random.randn(1, 3, 256, 256).astype(np.float32),), 0)
              for i in range(100)
          ]
  
          # Run nebullvm optimization in one line of code
          optimized_model = optimize_model(
              model_path,
              input_data=input_data,
              ignore_compilers=[
                  compiler
                  for compiler in COMPILER_LIST
                  if compiler != "tensor_rt"
              ],
              ignore_compressors=[
                  compressor for compressor in COMPRESSOR_LIST
              ],
          )
  
          # Try the optimized model
          device = torch.device(
              "cuda" if torch.cuda.is_available() else "cpu"
          )
          x = torch.randn(1, 3, 256, 256, requires_grad=False)
          model.to(device).eval()
          with torch.inference_mode():
              res_original = model(x.to(device))
          res_optimized = optimized_model(x.numpy())[0]
  
          assert isinstance(
              optimized_model, NumpyONNXTensorRTInferenceLearner
          )
          assert (
              abs(
                  (res_original.detach().cpu().numpy() - res_optimized)
              ).max()
              < 1e-2
          )
  
file_path: nebuly/optimization/speedster/speedster/api/tests/test_onnx.py
imports: import cpuinfo
  from tempfile import TemporaryDirectory
  import numpy
  import pytest
  import torch
  from nebullvm.config import COMPILER_LIST, COMPRESSOR_LIST
  from nebullvm.operations.inference_learners.onnx import NumpyONNXInferenceLearner
  from nebullvm.operations.inference_learners.openvino import NumpyOpenVinoInferenceLearner
  from nebullvm.operations.inference_learners.tensor_rt import NumpyONNXTensorRTInferenceLearner
  from nebullvm.operations.inference_learners.tvm import NumpyApacheTVMInferenceLearner
  from nebullvm.operations.optimizations.compilers.utils import tvm_is_available
  from torchvision import models
  from speedster import optimize_model, load_model
  from speedster.api.tests.utils import torch_to_onnx
label_desc: Use image node_id 3 for calling a global function with example usage: test_onnx_tensorrt() without return types