code: def _graph_to_net(cls, onnx_graph, opset_version):
      net = caffe2_pb2.NetDef()
      for node in onnx_graph.node:
          try:
              c2ops = cls._onnx_node_to_caffe2_op(
                  None, None, node, opset_version
              )
          except Exception as e:
              print("ONNX FATAL:", e)
              continue
          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 onnx_graph.output
      )
      net.external_input.extend(
          value_info.name for value_info in onnx_graph.input
      )
      return 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 22 for calling the Caffe2Backend obj's underlying member method code with example usage: obj._graph_to_net(cls, onnx_graph, opset_version) and returns: net