class_docstr: Make a detectron2 model traceable with Caffe2 operators.
  This class creates a traceable version of a detectron2 model which:
  
  1. Rewrite parts of the model using ops in Caffe2. Note that some ops do
     not have GPU implementation in Caffe2.
  2. Remove post-processing and only produce raw layer outputs
  
  After making a traceable model, the class provide methods to export such a
  model to different deployment formats.
  Exported graph produced by this class take two input tensors:
  
  1. (1, C, H, W) float "data" which is an image (usually in [0, 255]).
     (H, W) often has to be padded to multiple of 32 (depend on the model
     architecture).
  2. 1x3 float "im_info", each row of which is (height, width, 1.0).
     Height and width are true image shapes before padding.
  
  The class currently only supports models using builtin meta architectures.
  Batch inference is not supported, and contributions are welcome.
docstr: Args:
      cfg (CfgNode): a detectron2 config used to construct caffe2-compatible model.
      model (nn.Module): An original pytorch model. Must be among a few official models
          in detectron2 that can be converted to become caffe2-compatible automatically.
          Weights have to be already loaded to this model.
      inputs: sample inputs that the given model takes for inference.
          Will be used to trace the model. For most models, random inputs with
          no detected objects will not work as they lead to wrong traces.
docstr_tok: ["Args",":","cfg","(","CfgNode",")",":","a","detectron2","config","used","to","construct","caffe2-compatible","model",".","model","(","nn.Module",")",":","An","original","pytorch","model",".","Must","be","among","a","few","official","models","in","detectron2","that","can","be","converted","to","become","caffe2-compatible","automatically",".","Weights","have","to","be","already","loaded","to","this","model",".","inputs",":","sample","inputs","that","the","given","model","takes","for","inference",".","Will","be","used","to","trace","the","model",".","For","most","models",",","random","inputs","with","no","detected","objects","will","not","work","as","they","lead","to","wrong","traces","."]
code: def __init__(self, cfg: CfgNode, model: nn.Module, inputs):
      """
      Args:
          cfg (CfgNode): a detectron2 config used to construct caffe2-compatible model.
          model (nn.Module): An original pytorch model. Must be among a few official models
              in detectron2 that can be converted to become caffe2-compatible automatically.
              Weights have to be already loaded to this model.
          inputs: sample inputs that the given model takes for inference.
              Will be used to trace the model. For most models, random inputs with
              no detected objects will not work as they lead to wrong traces.
      """
      assert isinstance(cfg, CfgNode), cfg
      assert isinstance(model, torch.nn.Module), type(model)
  
      # TODO make it support custom models, by passing in c2 model directly
      C2MetaArch = META_ARCH_CAFFE2_EXPORT_TYPE_MAP[
          cfg.MODEL.META_ARCHITECTURE
      ]
      self.traceable_model = C2MetaArch(cfg, copy.deepcopy(model))
      self.inputs = inputs
      self.traceable_inputs = self.traceable_model.get_caffe2_inputs(
          inputs
      )
  
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 1 to create a new Caffe2Tracer object  with example: obj = Caffe2Tracer(cfg, model, inputs)