code: def export(
      model: Union[
          "PreTrainedModel", "TFPreTrainedModel", "ModelMixin"
      ],
      config: OnnxConfig,
      output: Path,
      opset: Optional[int] = None,
      device: str = "cpu",
      input_shapes: Optional[Dict] = None,
      disable_dynamic_axes_fix: Optional[bool] = False,
      dtype: Optional[str] = None,
      model_kwargs: Optional[Dict[str, Any]] = None,
  ) -> Tuple[List[str], List[str]]:
      """
      Exports a Pytorch or TensorFlow model to an ONNX Intermediate Representation.
  
      Args:
          model ([`PreTrainedModel`] or [`TFPreTrainedModel`]):
              The model to export.
          config ([`~exporters.onnx.config.OnnxConfig`]):
              The ONNX configuration associated with the exported model.
          output (`Path`):
              Directory to store the exported ONNX model.
          opset (`Optional[int]`, defaults to `None`):
              The version of the ONNX operator set to use.
          device (`Optional[str]`, defaults to `"cpu"`):
              The device on which the ONNX model will be exported. Either `cpu` or `cuda`. Only PyTorch is supported for
              export on CUDA devices.
          input_shapes (`Optional[Dict]`, defaults to `None`):
              If specified, allows to use specific shapes for the example input provided to the ONNX exporter.
          disable_dynamic_axes_fix (`Optional[bool]`, defaults to `False`):
              Whether to disable the default dynamic axes fixing.
          dtype (`Optional[str]`, defaults to `None`):
              Data type to remap the model inputs to. PyTorch-only. Only `fp16` is supported.
          model_kwargs (`Optional[Dict[str, Any]]`, defaults to `None`):
              Experimental usage: keyword arguments to pass to the model during
              the export. This argument should be used along the `custom_onnx_config` argument
              in case, for example, the model inputs/outputs are changed (for example, if
              `model_kwargs={"output_attentions": True}` is passed).
  
      Returns:
          `Tuple[List[str], List[str]]`: A tuple with an ordered list of the model's inputs, and the named outputs from
          the ONNX configuration.
      """
      if not (is_torch_available() or is_tf_available()):
          raise ImportError(
              "Cannot convert because neither PyTorch nor TensorFlow are installed. "
              "Please install torch or tensorflow first."
          )
  
      output.parent.mkdir(parents=True, exist_ok=True)
  
      export_output = None
  
      if opset is None:
          opset = config.DEFAULT_ONNX_OPSET
  
      if (
          "diffusers" in str(model.__class__)
          and not is_diffusers_available()
      ):
          raise ImportError(
              "The pip package `diffusers` is required to export stable diffusion models to ONNX."
          )
  
      if not config.is_transformers_support_available:
          import transformers
  
          raise MinimumVersionError(
              f"The current version of Transformers does not allow for the export of the model. Minimum required is "
              f"{config.MIN_TRANSFORMERS_VERSION}, got: {transformers.__version__}"
          )
  
      if is_torch_available() and isinstance(model, nn.Module):
          from ...utils import torch_version
  
          if not is_torch_onnx_support_available():
              raise MinimumVersionError(
                  f"Unsupported PyTorch version, minimum required is {TORCH_MINIMUM_VERSION}, got: {torch_version}"
              )
  
          if not config.is_torch_support_available:
              raise MinimumVersionError(
                  f"Unsupported PyTorch version for this model. Minimum required is {config.MIN_TORCH_VERSION},"
                  f" got: {torch.__version__}"
              )
  
          torch_dtype = None
          if dtype == "fp16":
              torch_dtype = torch.float16
          elif dtype is not None:
              raise ValueError(
                  "Unsupported dtype, supported dtypes are: `torch.float16`."
              )
  
          export_output = export_pytorch(
              model,
              config,
              opset,
              output,
              device=device,
              input_shapes=input_shapes,
              dtype=torch_dtype,
              model_kwargs=model_kwargs,
          )
  
      elif is_tf_available() and issubclass(
          type(model), TFPreTrainedModel
      ):
          if model_kwargs is not None:
              raise NotImplementedError(
                  "The argument `model_kwargs` is used only for PyTorch ONNX export, and unavailable for the Tensorflow export."
              )
          if device == "cuda":
              raise RuntimeError(
                  "`tf2onnx` does not support export on CUDA device."
              )
          if input_shapes is not None:
              logger.info(
                  "`input_shapes` argument is not supported by the Tensorflow ONNX export and will be ignored."
              )
          export_output = export_tensorflow(
              model, config, opset, output
          )
  
      else:
          raise RuntimeError(
              "You either provided a PyTorch model with only TensorFlow installed, or a TensorFlow model with only PyTorch installed."
          )
  
      if not disable_dynamic_axes_fix:
          config.fix_dynamic_axes(
              output,
              device=device,
              input_shapes=input_shapes,
              dtype=dtype,
          )
      return export_output
  
imports: import copy
  import gc
  import multiprocessing
  import os
  import traceback
  from inspect import signature
  from itertools import chain
  from pathlib import Path
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  import onnx
  from transformers.utils import is_tf_available, is_torch_available
  from ...onnx.utils import _get_onnx_external_data_tensors, check_model_uses_external_data
  from ...utils import TORCH_MINIMUM_VERSION, is_diffusers_available, is_torch_onnx_support_available, logging, require_numpy_strictly_lower
  from ..error_utils import AtolError, MinimumVersionError, OutputMatchError, ShapeError
  from .base import OnnxConfig
  from .model_configs import SpeechT5OnnxConfig
  from .utils import PickableInferenceSession, recursive_to_device
label_desc: Use image node_id 8 for calling a global function with example usage: export(model, config, output, opset, device, input_shapes, disable_dynamic_axes_fix, dtype, model_kwargs) and returns: export_output