code: def export(
      context, export_json, model, output_path, output_onnx_path
  ):
      """Convert a pytext model snapshot to a caffe2 model."""
      # only populate from export_json if no export option is configured from the command line.
      if export_json:
          if not output_path and not output_onnx_path:
              export_json_config = (
                  _load_and_validate_export_json_config(export_json)
              )
              export_section_config = export_json_config["export"]
              if "export_caffe2_path" in export_section_config:
                  output_path = export_section_config[
                      "export_caffe2_path"
                  ]
              if "export_onnx_path" in export_section_config:
                  output_onnx_path = export_section_config[
                      "export_onnx_path"
                  ]
          else:
              print(
                  "the export-json config is ignored because export options are found the command line"
              )
      config = context.obj.load_config()
      model = model or config.save_snapshot_path
      if config.export:
          output_path = output_path or config.export_caffe2_path
          output_onnx_path = output_onnx_path or config.export_onnx_path
          print(
              f"Exporting {model} to caffe2 file: {output_path} and onnx file: {output_onnx_path}"
          )
          export_saved_model_to_caffe2(
              model, output_path, output_onnx_path
          )
      else:
          for idx in range(0, len(config.export_list)):
              output_path = (
                  output_path or config.get_export_caffe2_path(idx)
              )
              output_onnx_path = (
                  output_onnx_path or config.get_export_onnx_path(idx)
              )
              print(
                  f"Exporting {model} to caffe2 file: {output_path} and onnx file: {output_onnx_path}"
              )
              export_saved_model_to_caffe2(
                  model, output_path, output_onnx_path
              )
  
imports: import json
  import pprint
  import sys
  import tempfile
  from importlib import import_module
  from pydoc import locate
  from typing import Dict, List, Optional, Union
  import click
  import torch
  from pytext import create_predictor
  from pytext.builtin_task import add_include
  from pytext.common.utils import eprint
  from pytext.config import ExportConfig, LATEST_VERSION, PyTextConfig
  from pytext.config.component import register_tasks
  from pytext.config.config_adapter import upgrade_to_latest
  from pytext.config.serialize import config_from_json, config_to_json, parse_config, pytext_config_from_json
  from pytext.config.utils import find_param, replace_param
  from pytext.data.data_handler import CommonMetadata
  from pytext.metric_reporters.channel import Channel, TensorBoardChannel
  from pytext.PreprocessingMap.ttypes import ModelType
  from pytext.task import load
  from pytext.utils.documentation import find_config_class, get_subclasses, pretty_print_config_class, replace_components, ROOT_CONFIG
  from pytext.utils.file_io import PathManager
  from pytext.workflow import export_saved_model_to_caffe2, export_saved_model_to_torchscript, get_logits, prepare_task_metadata, save_pytext_snapshot, test_model_from_snapshot_path, train_model
  from torch.multiprocessing.spawn import spawn
label_desc: Use image node_id 13 for calling a global function with example usage: export(context, export_json, model, output_path, output_onnx_path) without return types