code: def onnx_export(
      net_id: str | None = None,
      filepath: PathLike | None = None,
      ckpt_file: str | None = None,
      meta_file: str | Sequence[str] | None = None,
      config_file: str | Sequence[str] | None = None,
      key_in_ckpt: str | None = None,
      use_trace: bool | None = None,
      input_shape: Sequence[int] | None = None,
      args_file: str | None = None,
      converter_kwargs: Mapping | None = None,
      **override: Any,
  ) -> None:
      """
      Export the model checkpoint to an onnx model.
  
      Typical usage examples:
  
      .. code-block:: bash
  
          python -m monai.bundle onnx_export network --filepath <export path> --ckpt_file <checkpoint path> ...
  
      Args:
          net_id: ID name of the network component in the config, it must be `torch.nn.Module`.
          filepath: filepath where the onnx model is saved to.
          ckpt_file: filepath of the model checkpoint to load.
          meta_file: filepath of the metadata file, if it is a list of file paths, the content of them will be merged.
          config_file: filepath of the config file that contains extract network information,
          key_in_ckpt: for nested checkpoint like `{"model": XXX, "optimizer": XXX, ...}`, specify the key of model
              weights. if not nested checkpoint, no need to set.
          use_trace: whether using `torch.jit.trace` to convert the pytorch model to torchscript model.
          input_shape: a shape used to generate the random input of the network, when converting the model to an
              onnx model. Should be a list like [N, C, H, W] or [N, C, H, W, D]. If not given, will try to parse from
              the `metadata` config.
          args_file: a JSON or YAML file to provide default values for all the parameters of this function, so that
              the command line inputs can be simplified.
          converter_kwargs: extra arguments that are needed by `convert_to_onnx`, except ones that already exist in the
              input parameters.
          override: id-value pairs to override or add the corresponding config content.
              e.g. ``--_meta#network_data_format#inputs#image#num_channels 3``.
  
      """
      _args = update_kwargs(
          args=args_file,
          net_id=net_id,
          filepath=filepath,
          meta_file=meta_file,
          config_file=config_file,
          ckpt_file=ckpt_file,
          key_in_ckpt=key_in_ckpt,
          use_trace=use_trace,
          input_shape=input_shape,
          converter_kwargs=converter_kwargs,
          **override,
      )
      _log_input_summary(tag="onnx_export", args=_args)
      (
          filepath_,
          ckpt_file_,
          config_file_,
          net_id_,
          meta_file_,
          key_in_ckpt_,
          use_trace_,
          input_shape_,
          converter_kwargs_,
      ) = _pop_args(
          _args,
          "filepath",
          "ckpt_file",
          "config_file",
          net_id="",
          meta_file=None,
          key_in_ckpt="",
          use_trace=False,
          input_shape=None,
          converter_kwargs={},
      )
  
      parser = ConfigParser()
  
      parser.read_config(f=config_file_)
      if meta_file_ is not None:
          parser.read_meta(f=meta_file_)
  
      # the rest key-values in the _args are to override config content
      for k, v in _args.items():
          parser[k] = v
  
      # The convert_to_onnx must have an `inputs` as input, no matter what the `use_trace` is.
      # If the `input_shape` is not provided, will try to parse it from the parser to generate a random `inputs`.
      if not input_shape_:
          input_shape_ = _get_fake_input_shape(parser=parser)
  
      inputs_ = [torch.rand(input_shape_)]
      net = parser.get_parsed_content(net_id_)
      if has_ignite:
          # here we use ignite Checkpoint to support nested weights and be compatible with MONAI CheckpointSaver
          Checkpoint.load_objects(
              to_load={key_in_ckpt_: net}, checkpoint=ckpt_file_
          )
      else:
          ckpt = torch.load(ckpt_file_)
          copy_model_state(
              dst=net,
              src=ckpt if key_in_ckpt_ == "" else ckpt[key_in_ckpt_],
          )
  
      converter_kwargs_.update(
          {"inputs": inputs_, "use_trace": use_trace_}
      )
      onnx_model = convert_to_onnx(model=net, **converter_kwargs_)
      onnx.save(onnx_model, filepath_)
  
imports: from __future__ import annotations
  import ast
  import json
  import os
  import re
  import warnings
  from collections.abc import Mapping, Sequence
  from pathlib import Path
  from pydoc import locate
  from shutil import copyfile
  from textwrap import dedent
  from typing import Any, Callable
  import torch
  from torch.cuda import is_available
  from monai.apps.mmars.mmars import _get_all_ngc_models
  from monai.apps.utils import _basename, download_url, extractall, get_logger
  from monai.bundle.config_item import ConfigComponent
  from monai.bundle.config_parser import ConfigParser
  from monai.bundle.utils import DEFAULT_INFERENCE, DEFAULT_METADATA
  from monai.bundle.workflows import BundleWorkflow, ConfigWorkflow
  from monai.config import IgniteInfo, PathLike
  from monai.data import load_net_with_metadata, save_net_with_metadata
  from monai.networks import convert_to_onnx, convert_to_torchscript, convert_to_trt, copy_model_state, get_state_dict, save_state
  from monai.utils import check_parent_dir, deprecated_arg, ensure_tuple, get_equivalent_dtype, min_version, optional_import, pprint_edges
label_desc: Use image node_id 30 for calling a global function with example usage: onnx_export(net_id, filepath, ckpt_file, meta_file, config_file, key_in_ckpt, use_trace, input_shape, args_file, converter_kwargs) without return types