code: def from_onnx(graph, onnx_ir_version):  # type: (GraphProto) -> Graph
      input_tensors = {
          t.name: numpy_helper.to_array(t) for t in graph.initializer
      }
      nodes_ = []
      nodes_by_input = {}  # type: Dict[Text, List[Node]]
      nodes_by_output = {}
      for node in graph.node:
          node_ = Node.from_onnx(node)
          for input_ in node_.inputs:
              if input_ in input_tensors:
                  node_.input_tensors[input_] = input_tensors[input_]
              else:
                  if input_ in nodes_by_input:
                      input_nodes = nodes_by_input[input_]
                  else:
                      input_nodes = []
                      nodes_by_input[input_] = input_nodes
                  input_nodes.append(node_)
          for output_ in node_.outputs:
              nodes_by_output[output_] = node_
          nodes_.append(node_)
  
      inputs = []
      for i in graph.input:
          if i.name not in input_tensors:
              inputs.append(_input_from_onnx_input(i))
  
      outputs = []
      for o in graph.output:
          outputs.append(_input_from_onnx_input(o))
  
      for node_ in nodes_:
          for input_ in node_.inputs:
              if input_ in nodes_by_output:
                  node_.parents.append(nodes_by_output[input_])
          for output_ in node_.outputs:
              if output_ in nodes_by_input:
                  node_.children.extend(nodes_by_input[output_])
  
      # Dictionary to hold the "value_info" field from ONNX graph
      shape_dict = {}  # type: Dict[Text,Tuple[int,...]]
  
      def extract_value_info(
          shape_dict,  # type: Dict[Text,Tuple[int,...]]
          value_info,  # type: ValueInfoProto[...]
      ):
          # type: (...) -> None
          t = tuple(
              [
                  int(dim.dim_value)
                  for dim in value_info.type.tensor_type.shape.dim
              ]
          )
          if t:
              shape_dict[value_info.name] = t
  
      for value_info in graph.value_info:
          extract_value_info(shape_dict, value_info)
      for value_info in graph.input:
          extract_value_info(shape_dict, value_info)
      for value_info in graph.output:
          extract_value_info(shape_dict, value_info)
  
      return Graph(nodes_, inputs, outputs, shape_dict, onnx_ir_version)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from onnx import numpy_helper, ValueInfoProto, AttributeProto, GraphProto, NodeProto, TensorProto, TensorShapeProto
  from typing import Any, Text, Iterable, List, Dict, Sequence, Optional, Tuple, Union
  from typing_extensions import Protocol
  import numpy
label_desc: Use image node_id 6 for calling the Graph obj's underlying member method code with example usage: obj.from_onnx(graph, onnx_ir_version) and returns: Graph