code: def test_onnx_optimize_for_inference(
      dataset_name, model_names, text_backbone, image_backbone
  ):
      dataset = ALL_DATASETS[dataset_name]
      hyperparameters = {
          "optimization.max_epochs": 1,
          "model.names": model_names,
          "env.num_workers": 0,
          "env.num_workers_evaluation": 0,
      }
      if text_backbone:
          hyperparameters.update(
              {
                  "model.hf_text.checkpoint_name": text_backbone,
              }
          )
      if image_backbone:
          hyperparameters.update(
              {
                  "model.timm_image.checkpoint_name": image_backbone,
              }
          )
      predictor = MultiModalPredictor(
          label=dataset.label_columns[0],
          problem_type=dataset.problem_type,
          eval_metric=dataset.metric,
      )
      predictor.fit(
          train_data=dataset.train_df,
          hyperparameters=hyperparameters,
          time_limit=5,
      )
      model_path = predictor.path
      predictor.save(path=model_path)
  
      # Use a different subset of the dataset for compilation.
      tail_df = dataset.test_df.tail(2)
  
      # Load a refresh predictor and optimize it for inference
      for providers in [
          None,
          ["TensorrtExecutionProvider"],
          ["CUDAExecutionProvider"],
          ["CPUExecutionProvider"],
      ]:
          predictor_opt = MultiModalPredictor.load(path=model_path)
          predictor_opt.optimize_for_inference(providers=providers)
  
          # Check module type of optimized predictor
          assert isinstance(
              predictor_opt._learner._model, OnnxModule
          ), f"invalid onnx module type, expected to be OnnxModule, but the model type is {type(predictor_opt._learner._model)}"
  
          # We should support dynamic shape
          for batch_size in [2, 4, 8]:
              test_df = dataset.test_df.head(batch_size)
              if dataset.problem_type == REGRESSION:
                  y_pred = predictor.predict(test_df)
                  y_pred_trt = predictor_opt.predict(test_df)
              else:
                  y_pred = predictor.predict_proba(test_df)
                  y_pred_trt = predictor_opt.predict_proba(test_df)
              numpy.testing.assert_allclose(
                  y_pred, y_pred_trt, rtol=0.01, atol=0.01
              )
  
file_path: autogluon/multimodal/tests/unittests/others/test_deployment_onnx.py
imports: import os
  import shutil
  import numpy
  import numpy.testing
  import pytest
  from packaging import version
  from scipy.stats import pearsonr, spearmanr
  from sklearn.metrics.pairwise import paired_cosine_distances
  from autogluon.multimodal import MultiModalPredictor
  from autogluon.multimodal.constants import REGRESSION
  from autogluon.multimodal.utils.misc import shopee_dataset
  from autogluon.multimodal.utils.onnx import OnnxModule
  from ..utils.unittest_datasets import AEDataset, PetFinderDataset
label_desc: Use image node_id 4 for calling a global function with example usage: test_onnx_optimize_for_inference(dataset_name, model_names, text_backbone, image_backbone) without return types