def parse_graph_nodes(graph_def):
  """Helper function to parse GraphDef's nodes.

  It returns a dict mapping from node name to NodeDef.

  Args:
    graph_def: A GraphDef object.

  Returns:
    name_to_node: Dict keyed by node name, each entry containing the node's
      NodeDef.
  """
  name_to_node = {}
  for node_def in graph_def.node:
    name_to_node[node_def.name] = node_def
  return name_to_node