docstr: Export this predictor's model to ONNX file.
  
  When `path` argument is not provided, the method would not save the model into disk.
  Instead, it would export the onnx model into BytesIO and return its binary as bytes.
  
  Parameters
  ----------
  data
      Raw data used to trace and export the model.
      If this is None, will check if a processed batch is provided.
  path : str, default=None
      The export path of onnx model. If path is not provided, the method would export model to memory.
  batch_size
      The batch_size of export model's input.
      Normally the batch_size is a dynamic axis, so we could use a small value for faster export.
  verbose
      verbose flag in torch.onnx.export.
  opset_version
      opset_version flag in torch.onnx.export.
  truncate_long_and_double: bool, default False
      Truncate weights provided in int64 or double (float64) to int32 and float32
  
  Returns
  -------
  onnx_path : str or bytes
      A string that indicates location of the exported onnx model, if `path` argument is provided.
      Otherwise, would return the onnx model as bytes.
docstr_tok: ["Export","this","predictor","'s","model","to","ONNX","file",".","When","`","path","`","argument","is","not","provided",",","the","method","would","not","save","the","model","into","disk",".","Instead",",","it","would","export","the","onnx","model","into","BytesIO","and","return","its","binary","as","bytes",".","Parameters","--","--","--","--","--","data","Raw","data","used","to","trace","and","export","the","model",".","If","this","is","None",",","will","check","if","a","processed","batch","is","provided",".","path",":","str",",","default=None","The","export","path","of","onnx","model",".","If","path","is","not","provided",",","the","method","would","export","model","to","memory",".","batch_size","The","batch_size","of","export","model","'s","input",".","Normally","the","batch_size","is","a","dynamic","axis",",","so","we","could","use","a","small","value","for","faster","export",".","verbose","verbose","flag","in","torch.onnx.export",".","opset_version","opset_version","flag","in","torch.onnx.export",".","truncate_long_and_double",":","bool",",","default","False","Truncate","weights","provided","in","int64","or","double","(","float64",")","to","int32","and","float32","Returns","--","--","--","-","onnx_path",":","str","or","bytes","A","string","that","indicates","location","of","the","exported","onnx","model",",","if","`","path","`","argument","is","provided",".","Otherwise",",","would","return","the","onnx","model","as","bytes","."]
code: def export_onnx(
      self,
      data: Union[dict, pd.DataFrame],
      path: Optional[str] = None,
      batch_size: Optional[int] = None,
      verbose: Optional[bool] = False,
      opset_version: Optional[int] = 16,
      truncate_long_and_double: Optional[bool] = False,
  ):
      """
      Export this predictor's model to ONNX file.
  
      When `path` argument is not provided, the method would not save the model into disk.
      Instead, it would export the onnx model into BytesIO and return its binary as bytes.
  
      Parameters
      ----------
      data
          Raw data used to trace and export the model.
          If this is None, will check if a processed batch is provided.
      path : str, default=None
          The export path of onnx model. If path is not provided, the method would export model to memory.
      batch_size
          The batch_size of export model's input.
          Normally the batch_size is a dynamic axis, so we could use a small value for faster export.
      verbose
          verbose flag in torch.onnx.export.
      opset_version
          opset_version flag in torch.onnx.export.
      truncate_long_and_double: bool, default False
          Truncate weights provided in int64 or double (float64) to int32 and float32
  
      Returns
      -------
      onnx_path : str or bytes
          A string that indicates location of the exported onnx model, if `path` argument is provided.
          Otherwise, would return the onnx model as bytes.
      """
  
      import torch.jit
  
      from ..models.fusion.fusion_mlp import MultimodalFusionMLP
      from ..models.huggingface_text import HFAutoModelForTextPrediction
      from ..models.timm_image import TimmAutoModelForImagePrediction
  
      supported_models = (
          TimmAutoModelForImagePrediction,
          HFAutoModelForTextPrediction,
          MultimodalFusionMLP,
      )
      if not isinstance(self._model, supported_models):
          raise NotImplementedError(
              f"export_onnx doesn't support model type {type(self._model)}"
          )
      warnings.warn(
          "Currently, the functionality of exporting to ONNX is experimental."
      )
  
      # Data preprocessing, loading, and filtering
      batch = self.get_processed_batch_for_deployment(
          data=data,
          onnx_tracing=True,
          batch_size=batch_size,
          truncate_long_and_double=truncate_long_and_double,
      )
      input_keys = self._model.input_keys
      input_vec = [batch[k] for k in input_keys]
  
      # Write to BytesIO if path argument is not provided
      if path is None:
          onnx_path = io.BytesIO()
      else:
          onnx_path = os.path.join(path, "model.onnx")
          dirname = os.path.dirname(os.path.abspath(onnx_path))
          if not os.path.exists(dirname):
              os.makedirs(dirname)
  
      # Infer dynamic dimensions
      dynamic_axes = onnx_get_dynamic_axes(input_keys)
  
      torch.onnx.export(
          self._model.eval(),
          args=tuple(input_vec),
          f=onnx_path,
          opset_version=opset_version,
          verbose=verbose,
          input_names=input_keys,
          dynamic_axes=dynamic_axes,
      )
  
      if isinstance(onnx_path, io.BytesIO):
          onnx_path = onnx_path.getvalue()
  
      return onnx_path
  
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 2 for calling the ExportMixin obj's underlying member method code with example usage: obj.export_onnx(data, path, batch_size, verbose, opset_version, truncate_long_and_double) and returns: onnx_path