code: def to_onnx(model: nn.Module, example_inputs: Any) -> Any:
      """Helper function to convert a model to onnx model."""
      try:
          import onnx
          import onnxsim
          import onnxruntime
      except ImportError:
          _logger.error(
              "Please install onnx, onnxruntime, onnxsim to use this function."
          )
          raise
  
      with tempfile.TemporaryFile() as fp:
          torch.onnx.export(model, example_inputs, fp, export_params=False)  # type: ignore
          fp.seek(0)
          model = onnx.load(fp, load_external_data=False)  # type: ignore
  
      model_simp, check = onnxsim.simplify(model)
      if not check:
          _logger.error(
              f"Check did not pass when simplifying the module with onnxsim. Trying without simplification: {model}"
          )
          model_simp = model
  
      return model_simp
  
imports: from __future__ import annotations
  import functools
  import logging
  import tempfile
  from typing import Any, Iterable
  import torch
  from torch import nn
  from nn_meter import load_latency_predictor, nnMeterPredictor
  from nni.mutable import Mutable, MutableList, LabeledMutable, Sample, MutableExpression
  from nni.nas.nn.pytorch import ModelSpace, MutableModule, LayerChoice, Repeat
  from nni.nas.profiler import ExpressionProfiler
  from .utils import MutableShape, ShapeTensor, standardize_arguments, submodule_input_output_shapes, is_leaf_module, concat_name
label_desc: Use image node_id 1 for calling a global function with example usage: to_onnx(model, example_inputs) and returns: model_simp