def METHOD_NAME(block_node):
  top_graph = Graph(block_node.name)
  top_block = block_node.blocks[0]
  top_graph.add_block(top_block)
  top_graph.set_top_block(top_block)
  top_block.owning_graph = top_graph
  def node_visitor(node, fn):
    if node.blocks:
      for block in node.blocks:
        for b_n in block:
          node_visitor(node, fn)
    else:
      fn(node)
  def visit_fn(n):
    n.owning_graph = top_graph
    for i_t in n.in_tensors:
      top_graph.add_tensor(i_t)
    for o_t in n.out_tensors:
      top_graph.add_tensor(o_t)
    for _, p_t in n.op.params.items():
      top_graph.add_param_name(p_t.name)
  for node in top_block.nodes:
    node_visitor(node, visit_fn)
  return top_graph