code: def export_nets_to_predictor_file(
      c2_prepared,
      input_names,
      output_names,
      predictor_path,
      extra_params=None,
  ):
      # netdef external_input includes internally produced blobs
      actual_external_inputs = set()
      produced = set()
      for operator in c2_prepared.predict_net.op:
          for blob in operator.input:
              if blob not in produced:
                  actual_external_inputs.add(blob)
          for blob in operator.output:
              produced.add(blob)
      for blob in output_names:
          if blob not in produced:
              actual_external_inputs.add(blob)
  
      param_names = [
          blob
          for blob in actual_external_inputs
          if blob not in input_names and blob not in output_names
      ]
      if extra_params is not None:
          param_names += extra_params
  
      init_net = core.Net(c2_prepared.init_net)
      predict_net = core.Net(c2_prepared.predict_net)
  
      # Required because of https://github.com/pytorch/pytorch/pull/6456/files
      with c2_prepared.workspace._ctx:
          workspace.RunNetOnce(init_net)
          predictor_export_meta = pe.PredictorExportMeta(
              predict_net=predict_net,
              parameters=param_names,
              inputs=input_names,
              outputs=output_names,
              shapes={x: () for x in input_names + output_names},
              net_type="simple",
          )
          pe.save_to_db(
              db_type=CAFFE2_DB_TYPE,
              db_destination=predictor_path,
              predictor_export_meta=predictor_export_meta,
          )
  
file_path: pytext/pytext/utils/onnx.py
imports: import caffe2.python.predictor.predictor_exporter
  import numpy
  import torch
  from caffe2.python import core, workspace
  from caffe2.python.onnx import backend
  from torch.onnx import ExportTypes, OperatorExportTypes
label_desc: Use image node_id 7 for calling a global function with example usage: export_nets_to_predictor_file(c2_prepared, input_names, output_names, predictor_path, extra_params) without return types