code: def plot_graph(
      in_graph_ents, graph, entity_dict, print_out_label=True
  ) -> None:
      """Function to plot each wikipedia's subgraph.
  
      Args:
        in_graph_ents: all in-context entities
        graph: subgraph of each wikipage.
        entity_dict: entityID to name
        print_out_label: whether to print the intermediate label.
      """
      if not graph:
          return
      g = nx.Graph()
      all_label = {}
      in_label = {}
      for se in graph:
          all_label[entity_dict[se]] = entity_dict[se]
          if se in in_graph_ents:
              g.add_node(entity_dict[se], color="red", size=2000)
              in_label[entity_dict[se]] = entity_dict[se]
          if se not in in_graph_ents:
              g.add_node(entity_dict[se], color="blue", size=100)
          for te in graph[se]:
              all_label[entity_dict[te]] = entity_dict[te]
              if te in in_graph_ents:
                  g.add_node(entity_dict[te], color="red", size=2000)
                  in_label[entity_dict[te]] = entity_dict[te]
              if te not in in_graph_ents:
                  g.add_node(entity_dict[te], color="blue", size=100)
              g.add_edge(entity_dict[se], entity_dict[te])
      plt.figure(figsize=(10, 10))
      layout = nx.kamada_kawai_layout(g)
      if print_out_label:
          nx.draw_networkx_nodes(
              g,
              pos=layout,
              node_color=nx.get_node_attributes(g, "color").values(),
              node_size=list(
                  nx.get_node_attributes(g, "size").values()
              ),
          )
          nx.draw_networkx_labels(g, pos=layout, labels=all_label)
          nx.draw_networkx_edges(g, pos=layout, alpha=0.3, arrows=False)
      else:
          nx.draw_networkx_nodes(
              g,
              pos=layout,
              node_color=nx.get_node_attributes(g, "color").values(),
              node_size=list(
                  nx.get_node_attributes(g, "size").values()
              ),
          )
          nx.draw_networkx_labels(g, pos=layout, labels=in_label)
          nx.draw_networkx_edges(g, pos=layout, alpha=0.3, arrows=False)
      xs = np.array(list(layout.values()))[:, 0]
      xmin, xmax = np.min(xs), np.max(xs)
      plt.xlim(xmin - (xmax - xmin) * 0.2, xmax + (xmax - xmin) * 0.2)
      plt.show()
  
file_path: scenic/scenic/projects/knowledge_visual_language/data/wikidata/data_util.py
imports: import json
  from typing import Any, Dict, List
  import matplotlib.pyplot
  import networkx
  import numpy
  import tqdm
  import tensorflow
  from tf.io import gfile
label_desc: Use image node_id 4 for calling a global function with example usage: plot_graph(in_graph_ents, graph, entity_dict, print_out_label) without return types