docstr: For Onnx Caffe2Backend, we require that init_graph don't initialize the actual input of the predict_graph,
  
  for example, if "img" is the input blob for the predict_net, we require that in init_graph and in
  initializer of the predict_graph, "img" is not initalized. We don't have a check for this, since
  there is no way we can know which blob is the input of the predict_graph.
docstr_tok: ["For","Onnx","Caffe2Backend",",","we","require","that","init_graph","do","n't","initialize","the","actual","input","of","the","predict_graph",",","for","example",",","if","``","img","''","is","the","input","blob","for","the","predict_net",",","we","require","that","in","init_graph","and","in","initializer","of","the","predict_graph",",","``","img","''","is","not","initalized",".","We","do","n't","have","a","check","for","this",",","since","there","is","no","way","we","can","know","which","blob","is","the","input","of","the","predict_graph","."]
code: def prepare(cls, model, device="CPU", raw_values_dict=None, **kwargs):
      """
      For Onnx Caffe2Backend, we require that init_graph don't initialize the actual input of the predict_graph,
  
      for example, if "img" is the input blob for the predict_net, we require that in init_graph and in
      initializer of the predict_graph, "img" is not initalized. We don't have a check for this, since
      there is no way we can know which blob is the input of the predict_graph.
      """
      if not kwargs.pop("no_check_UNSAFE", False):
          super(Caffe2Backend, cls).prepare(model, device, **kwargs)
      opset_version = None
      for imp in model.opset_import:
          if not imp.HasField("domain") or imp.domain == "":
              opset_version = imp.version
              if imp.version > cls._known_opset_version:
                  warnings.warn(
                      "This version of onnx-caffe2 targets ONNX operator set version {}, but the model we are trying to import uses version {}.  We will try to import it anyway, but if the model uses operators which had BC-breaking changes in the intervening versions, import will fail.".format(
                          cls._known_opset_version, imp.version
                      )
                  )
          else:
              warnings.warn(
                  "Unrecognized operator set {}".format(imp.domain)
              )
      if opset_version is None:
          if model.ir_version >= 0x00000003:
              raise RuntimeError(
                  "Model with IR version >= 3 did not specify ONNX operator set version (onnx-caffe2 requires it)"
              )
          else:
              opset_version = 1
  
      # Prior to onnx version update to onnx-1.8.0, errors caused by failures in
      # in the onnx shape inference call were being supressed. Hence a try-catch block
      # is added around the infer_shapes call to avoid these failures and preserve status
      try:
          model = onnx.shape_inference.infer_shapes(model)
      except RuntimeError:
          warnings.warn(
              "ShapeInferenceWarning: Inferred shape and existing shape differ in rank"
          )
  
      ws = Workspace()
      device_option = get_device_option(Device(device))
  
      init_net, predict_net = cls._onnx_model_to_caffe2_net(
          model, device, opset_version, False
      )
  
      if raw_values_dict:
          cls._external_value_resolution_pass(model, raw_values_dict)
  
      # Directly load initializer data into blobs in workspace
      cls._direct_initialize_parameters(
          model.graph.initializer,
          ws,
          device_option,
      )
  
      initialized = {init.name for init in model.graph.initializer}
  
      cls._direct_initialize_inputs(
          model.graph.input,
          initialized,
          ws,
          device_option,
      )
  
      uninitialized = [
          value_info.name
          for value_info in model.graph.input
          if value_info.name not in initialized
      ]
  
      retval = Caffe2Rep(init_net, predict_net, ws, uninitialized)
      return retval
  
imports: import collections
  import sys
  import zipfile
  import itertools
  import onnx.backend
  from caffe2.python import core, workspace, rnn_cell, gru_cell
  from caffe2.python.model_helper import ModelHelper
  from caffe2.proto import caffe2_pb2
  import caffe2.python.utils
  import numpy
  import onnx
  from onnx import TensorProto
  import onnx.numpy_helper
  import onnx.defs
  import onnx.shape_inference
  import onnx.utils
  from onnx.backend.base import Backend, Device, DeviceType, namedtupledict
  from caffe2.python.onnx.workspace import Workspace
  from caffe2.python.onnx.backend_rep import Caffe2Rep
  import caffe2.python._import_c_extension
  import warnings
label_desc: Use image node_id 18 for calling the Caffe2Backend obj's underlying member method code with example usage: obj.prepare(cls, model, device, raw_values_dict) and returns: retval