code: def ckpt_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 the given filepath with metadata and config included as JSON files.
  
      Typical usage examples:
  
      .. code-block:: bash
  
          python -m monai.bundle ckpt_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`.
              Default to "network_def".
          filepath: filepath to export, if filename has no extension it becomes `.ts`.
              Default to "models/model.ts" under "os.getcwd()" if `bundle_root` is not specified.
          ckpt_file: filepath of the model checkpoint to load.
              Default to "models/model.pt" under "os.getcwd()" if `bundle_root` is not specified.
          meta_file: filepath of the metadata file, if it is a list of file paths, the content of them will be merged.
              Default to "configs/metadata.json" under "os.getcwd()" if `bundle_root` is not specified.
          config_file: filepath of the config file to save in TorchScript model and extract network information,
              the saved key in the TorchScript model is the config filename without extension, and the saved config
              value is always serialized in JSON format no matter the original file format is JSON or YAML.
              it can be a single file or a list of files. if `None`, must be provided in `args_file`.
          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 a
              TorchScript 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_torchscript`, 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="ckpt_export", args=_args)
      (
          config_file_,
          filepath_,
          ckpt_file_,
          net_id_,
          meta_file_,
          key_in_ckpt_,
          use_trace_,
          input_shape_,
          converter_kwargs_,
      ) = _pop_args(
          _args,
          "config_file",
          filepath=None,
          ckpt_file=None,
          net_id=None,
          meta_file=None,
          key_in_ckpt="",
          use_trace=False,
          input_shape=None,
          converter_kwargs={},
      )
      bundle_root = _args.get("bundle_root", os.getcwd())
  
      parser = ConfigParser()
      parser.read_config(f=config_file_)
      meta_file_ = (
          os.path.join(bundle_root, "configs", "metadata.json")
          if meta_file_ is None
          else meta_file_
      )
      if os.path.exists(meta_file_):
          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
  
      filepath_ = (
          os.path.join(bundle_root, "models", "model.ts")
          if filepath_ is None
          else filepath_
      )
      ckpt_file_ = (
          os.path.join(bundle_root, "models", "model.pt")
          if ckpt_file_ is None
          else ckpt_file_
      )
      if not os.path.exists(ckpt_file_):
          raise FileNotFoundError(
              f'Checkpoint file "{ckpt_file_}" not found, please specify it in argument "ckpt_file".'
          )
  
      net_id_ = "network_def" if net_id_ is None else net_id_
      try:
          parser.get_parsed_content(net_id_)
      except ValueError as e:
          raise ValueError(
              f'Network definition "{net_id_}" cannot be found in "{config_file_}", specify name with argument "net_id".'
          ) from e
  
      # When export through torch.jit.trace without providing input_shape, will try to parse one from the parser.
      if (not input_shape_) and use_trace:
          input_shape_ = _get_fake_input_shape(parser=parser)
  
      inputs_: Sequence[Any] | None = (
          [torch.rand(input_shape_)] if input_shape_ else None
      )
  
      converter_kwargs_.update(
          {"inputs": inputs_, "use_trace": use_trace_}
      )
      # Use the given converter to convert a model and save with metadata, config content
      _export(
          convert_to_torchscript,
          parser,
          net_id=net_id_,
          filepath=filepath_,
          ckpt_file=ckpt_file_,
          config_file=config_file_,
          key_in_ckpt=key_in_ckpt_,
          **converter_kwargs_,
      )
  
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 31 for calling a global function with example usage: ckpt_export(net_id, filepath, ckpt_file, meta_file, config_file, key_in_ckpt, use_trace, input_shape, args_file, converter_kwargs) without return types