code: def create_graph(predicted_ids, parent_ids, scores, vocab=None):
      def get_node_name(pred):
          return vocab[pred] if vocab else str(pred)
  
      seq_length = predicted_ids.shape[0]
      graph = nx.DiGraph()
      for level in range(seq_length):
          names = [get_node_name(pred) for pred in predicted_ids[level]]
          _add_graph_level(
              graph, level + 1, parent_ids[level], names, scores[level]
          )
      graph.node[(0, 0)]["name"] = "START"
      return graph
  
file_path: seq2seq/bin/tools/generate_beam_viz.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import argparse
  import os
  import json
  import shutil
  from string import Template
  import numpy
  import networkx
  from networkx.readwrite import json_graph
label_desc: Use image node_id 2 for calling a global function with example usage: create_graph(predicted_ids, parent_ids, scores, vocab) and returns: graph, unknown