class_docstr: A wrapper around the traced model in Caffe2's protobuf format.
  The exported graph has different inputs/outputs from the original Pytorch
  model, as explained in :class:`Caffe2Tracer`. This class wraps around the
  exported graph to simulate the same interface as the original Pytorch model.
  It also provides functions to save/load models in Caffe2's format.'
  
  Examples:
  ::
      c2_model = Caffe2Tracer(cfg, torch_model, inputs).export_caffe2()
      inputs = [{"image": img_tensor_CHW}]
      outputs = c2_model(inputs)
      orig_outputs = torch_model(inputs)
docstr: Save the model as caffe2's protobuf format.
  It saves the following files:
  
      * "model.pb": definition of the graph. Can be visualized with
        tools like `netron <https://github.com/lutzroeder/netron>`_.
      * "model_init.pb": model parameters
      * "model.pbtxt": human-readable definition of the graph. Not
        needed for deployment.
  
  Args:
      output_dir (str): the output directory to save protobuf files.
docstr_tok: ["Save","the","model","as","caffe2","'s","protobuf","format",".","It","saves","the","following","files",":","*","``","model.pb","''",":","definition","of","the","graph",".","Can","be","visualized","with","tools","like","`","netron","<","https",":","\/\/github.com\/lutzroeder\/netron",">","`","_",".","*","``","model_init.pb","''",":","model","parameters","*","``","model.pbtxt","''",":","human-readable","definition","of","the","graph",".","Not","needed","for","deployment",".","Args",":","output_dir","(","str",")",":","the","output","directory","to","save","protobuf","files","."]
code: def save_protobuf(self, output_dir):
      """
      Save the model as caffe2's protobuf format.
      It saves the following files:
  
          * "model.pb": definition of the graph. Can be visualized with
            tools like `netron <https://github.com/lutzroeder/netron>`_.
          * "model_init.pb": model parameters
          * "model.pbtxt": human-readable definition of the graph. Not
            needed for deployment.
  
      Args:
          output_dir (str): the output directory to save protobuf files.
      """
      logger = logging.getLogger(__name__)
      logger.info("Saving model to {} ...".format(output_dir))
      if not PathManager.exists(output_dir):
          PathManager.mkdirs(output_dir)
  
      with PathManager.open(
          os.path.join(output_dir, "model.pb"), "wb"
      ) as f:
          f.write(self._predict_net.SerializeToString())
      with PathManager.open(
          os.path.join(output_dir, "model.pbtxt"), "w"
      ) as f:
          f.write(str(self._predict_net))
      with PathManager.open(
          os.path.join(output_dir, "model_init.pb"), "wb"
      ) as f:
          f.write(self._init_net.SerializeToString())
  
imports: import copy
  import logging
  import os
  import torch
  from caffe2.proto import caffe2_pb2
  from torch import nn
  from detectron2.config import CfgNode
  from detectron2.utils.file_io import PathManager
  from .caffe2_inference import ProtobufDetectionModel
  from .caffe2_modeling import META_ARCH_CAFFE2_EXPORT_TYPE_MAP, convert_batched_inputs_to_c2_format
  from .shared import get_pb_arg_vali, get_pb_arg_vals, save_graph
label_desc: Use image node_id 4 for calling the Caffe2Model obj's underlying member method code with example usage: obj.save_protobuf(output_dir) without return types