code: def _onnx_model_to_caffe2_net(
      cls, onnx_model, device, opset_version, include_initializers
  ):
      device_option = get_device_option(Device(device))
  
      # 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:
          onnx_model = onnx.utils.polish_model(onnx_model)
      except RuntimeError:
          warnings.warn(
              "ShapeInferenceWarning: Inferred shape and existing shape differ in rank"
          )
      except AttributeError:
          warnings.warn(
              "ShapeInferenceWarning: utils module not found in ONNX version {}".format(
                  onnx.__version__
              )
          )
  
      # Optimizer module has been removed in ONNX-1.9 or later, warn caller if that is the case
      try:
          init_model = cls.optimize_onnx(onnx_model, init=True)
          pred_model = cls.optimize_onnx(onnx_model, predict=True)
      except ModuleNotFoundError:
          warnings.warn(
              "OptimizerWarning: onnxoptimizer module not installed. "
              "init_model and pred_model models will not be splitted, which can cause a runtime error"
          )
          init_model = onnx_model
          pred_model = onnx_model
  
      init_net = caffe2_pb2.NetDef()
      pred_net = caffe2_pb2.NetDef()
  
      init_net.name = onnx_model.graph.name + "_init"
      pred_net.name = onnx_model.graph.name + "_predict"
  
      if include_initializers:
          init_net.op.extend(
              cls._create_tensor_filling_op(tp)
              for tp in onnx_model.graph.initializer
          )
  
      cls._dummy_name.reset(
          cls._all_names_in_graph(init_model.graph)
          | cls._all_names_in_graph(pred_model.graph)
      )
  
      errors = []
      for net, model in (
          (init_net, init_model),
          (pred_net, pred_model),
      ):
          net.device_option.CopyFrom(device_option)
          for node in model.graph.node:
              try:
                  c2ops = cls._onnx_node_to_caffe2_op(
                      init_model, pred_model, node, opset_version
                  )
              except Exception as e:
                  msg = "Error while processing node: {}. Exception: {}".format(
                      node, e
                  )
                  errors.append(msg)
                  print("ONNX FATAL:", msg, file=sys.stderr)
                  continue
              init_net.op.extend(c2ops.init_ops)
              net.op.extend(c2ops.ops)
              net.external_input.extend(c2ops.interface_blobs)
          net.external_output.extend(
              value_info.name for value_info in model.graph.output
          )
          net.external_input.extend(
              value_info.name for value_info in model.graph.input
          )
  
      if len(errors) > 0:
          raise RuntimeError(
              "ONNX conversion failed, encountered {} errors:\n\n{}".format(
                  len(errors), "\n\n".join(errors)
              )
          )
  
      return init_net, pred_net
  
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 23 for calling the Caffe2Backend obj's underlying member method code with example usage: obj._onnx_model_to_caffe2_net(cls, onnx_model, device, opset_version, include_initializers) and returns: init_net,  pred_net