docstr: Optimize the predictor's model for inference.
  
  Under the hood, the implementation would convert the PyTorch module into an ONNX module, so that
  we can leverage efficient execution providers in onnxruntime for faster inference.
  
  Parameters
  ----------
  data
      Raw data used to trace and export the model.
      If this is None, will check if a processed batch is provided.
  providers : dict or str, default=None
      A list of execution providers for model prediction in onnxruntime.
  
      By default, the providers argument is None. The method would generate an ONNX module that
      would perform model inference with TensorrtExecutionProvider in onnxruntime, if tensorrt
      package is properly installed. Otherwise, the onnxruntime would fallback to use CUDA or CPU
      execution providers instead.
  
  Returns
  -------
  onnx_module : OnnxModule
      The onnx-based module that can be used to replace predictor._model for model inference.
docstr_tok: ["Optimize","the","predictor","'s","model","for","inference",".","Under","the","hood",",","the","implementation","would","convert","the","PyTorch","module","into","an","ONNX","module",",","so","that","we","can","leverage","efficient","execution","providers","in","onnxruntime","for","faster","inference",".","Parameters","--","--","--","--","--","data","Raw","data","used","to","trace","and","export","the","model",".","If","this","is","None",",","will","check","if","a","processed","batch","is","provided",".","providers",":","dict","or","str",",","default=None","A","list","of","execution","providers","for","model","prediction","in","onnxruntime",".","By","default",",","the","providers","argument","is","None",".","The","method","would","generate","an","ONNX","module","that","would","perform","model","inference","with","TensorrtExecutionProvider","in","onnxruntime",",","if","tensorrt","package","is","properly","installed",".","Otherwise",",","the","onnxruntime","would","fallback","to","use","CUDA","or","CPU","execution","providers","instead",".","Returns","--","--","--","-","onnx_module",":","OnnxModule","The","onnx-based","module","that","can","be","used","to","replace","predictor._model","for","model","inference","."]
code: def optimize_for_inference(
      self,
      providers: Optional[Union[dict, List[str]]] = None,
  ):
      """
      Optimize the predictor's model for inference.
  
      Under the hood, the implementation would convert the PyTorch module into an ONNX module, so that
      we can leverage efficient execution providers in onnxruntime for faster inference.
  
      Parameters
      ----------
      data
          Raw data used to trace and export the model.
          If this is None, will check if a processed batch is provided.
      providers : dict or str, default=None
          A list of execution providers for model prediction in onnxruntime.
  
          By default, the providers argument is None. The method would generate an ONNX module that
          would perform model inference with TensorrtExecutionProvider in onnxruntime, if tensorrt
          package is properly installed. Otherwise, the onnxruntime would fallback to use CUDA or CPU
          execution providers instead.
  
      Returns
      -------
      onnx_module : OnnxModule
          The onnx-based module that can be used to replace predictor._model for model inference.
      """
      data_dict = {}
      for col_name, col_type in self._column_types.items():
          if col_type in [NUMERICAL, CATEGORICAL, NULL]:
              data_dict[col_name] = [0, 1]
          elif col_type == TEXT:
              data_dict[col_name] = ["some text", "some other text"]
          elif col_type in [IMAGE_PATH]:
              data_dict[col_name] = [
                  "/not-exist-dir/xxx.jpg",
                  "/not-exist-dir/yyy.jpg",
              ]
          else:
              raise ValueError(f"unsupported column type: {col_type}")
      data = pd.DataFrame.from_dict(data_dict)
  
      onnx_module = None
      onnx_path = self.export_onnx(
          data=data, truncate_long_and_double=True
      )
  
      onnx_module = OnnxModule(onnx_path, providers)
      onnx_module.input_keys = self._model.input_keys
      onnx_module.prefix = self._model.prefix
      onnx_module.get_output_dict = self._model.get_output_dict
  
      # To use the TensorRT module for prediction, simply replace the _model in the predictor
      self._model = onnx_module
  
      # Evaluate and cache TensorRT engine files
      logger.info("Compiling ... (this may take a few minutes)")
      _ = self.predict(data)
      logger.info("Finished compilation!")
  
      return onnx_module
  
file_path: autogluon/multimodal/src/autogluon/multimodal/utils/export.py
imports: import io
  import logging
  import os
  import warnings
  from collections import defaultdict
  from typing import Dict, List, Optional, Union
  import pandas
  import torch
  from ..constants import CATEGORICAL, HF_TEXT, IMAGE_PATH, MMDET_IMAGE, NULL, NUMERICAL, TEXT, TIMM_IMAGE
  from ..models.fusion import AbstractMultimodalFusionModel
  from ..models.huggingface_text import HFAutoModelForTextPrediction
  from ..models.mmdet_image import MMDetAutoModelForObjectDetection
  from ..models.timm_image import TimmAutoModelForImagePrediction
  from .environment import infer_precision
  from .onnx import OnnxModule, onnx_get_dynamic_axes
label_desc: Use image node_id 3 for calling the ExportMixin obj's underlying member method code with example usage: obj.optimize_for_inference(providers) and returns: onnx_module