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: Args:
      dir (str): a directory used to save Caffe2Model with
          :meth:`save_protobuf`.
          The files "model.pb" and "model_init.pb" are needed.
  
  Returns:
      Caffe2Model: the caffe2 model loaded from this directory.
docstr_tok: ["Args",":","dir","(","str",")",":","a","directory","used","to","save","Caffe2Model","with",":","meth",":","`","save_protobuf","`",".","The","files","``","model.pb","''","and","``","model_init.pb","''","are","needed",".","Returns",":","Caffe2Model",":","the","caffe2","model","loaded","from","this","directory","."]
code: def load_protobuf(dir):
      """
      Args:
          dir (str): a directory used to save Caffe2Model with
              :meth:`save_protobuf`.
              The files "model.pb" and "model_init.pb" are needed.
  
      Returns:
          Caffe2Model: the caffe2 model loaded from this directory.
      """
      predict_net = caffe2_pb2.NetDef()
      with PathManager.open(os.path.join(dir, "model.pb"), "rb") as f:
          predict_net.ParseFromString(f.read())
  
      init_net = caffe2_pb2.NetDef()
      with PathManager.open(
          os.path.join(dir, "model_init.pb"), "rb"
      ) as f:
          init_net.ParseFromString(f.read())
  
      return Caffe2Model(predict_net, init_net)
  
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 6 for calling the Caffe2Model obj's underlying member method code with example usage: obj.load_protobuf(dir) and returns: Caffe2Model