code: def extract_graph_from_file(kg_graph, i) -> None:
      """Extract 2hop graphs for all pages in each file.
  
      Args:
        kg_graph: the global KG (i.e. WikiData Knowledge Graph), stored as dict.
        i: index of wiki file.
  
      Returns:
        A list of wikipedia pages with extracted graph.
      """
      d_list = data_util.load_wiki_from_file(
          os.path.join(data_util.WIKIPEDIA_LINK_PATH, "wiki_%d.txt" % i)
      )
      with gfile.Open(
          os.path.join(
              data_util.WIKIPEDIA_GRAPH_PATH, "wiki_graph_%d.txt" % i
          ),
          "w",
      ) as fopen:
          for d in d_list:
              if "link" in d and isinstance(d["link"], dict):
                  in_context_ents = {
                      ent: True for ent in d["link"] if ent != "UNK"
                  }
                  d["graph"] = data_util.extract_2hop_graph(
                      in_context_ents, kg_graph
                  )
              fopen.write(json.dumps(d) + "\n")
      del d_list
  
file_path: scenic/scenic/projects/knowledge_visual_language/data/wikidata/extract_wikigraph.py
imports: import json
  import multiprocessing
  import os
  from absl import app
  from absl import logging
  from scenic.projects.knowledge_visual_language.data.wikidata import data_util
  import tqdm
  import tensorflow
  from tf.io import gfile
label_desc: Use image node_id 1 for calling a global function with example usage: extract_graph_from_file(kg_graph, i) without return types