code: def write_txt_graph(
      path, file_name, part_dict, total_nodes, total_relations
  ):
      partition_book = [0] * total_nodes
      for part_id in part_dict:
          print("write graph %d..." % part_id)
          # Get (h,r,t) triples
          partition_path = path + str(part_id)
          if not os.path.exists(partition_path):
              os.mkdir(partition_path)
          triple_file = os.path.join(partition_path, file_name)
          f = open(triple_file, "w")
          graph = part_dict[part_id]
          src, dst = graph.all_edges(form="uv", order="eid")
          rel = graph.edata["tid"]
          assert len(src) == len(rel)
          src = F.asnumpy(src)
          dst = F.asnumpy(dst)
          rel = F.asnumpy(rel)
          for i in range(len(src)):
              f.write(
                  str(src[i])
                  + "\t"
                  + str(rel[i])
                  + "\t"
                  + str(dst[i])
                  + "\n"
              )
          f.close()
          # Get local2global
          l2g_file = os.path.join(partition_path, "local_to_global.txt")
          f = open(l2g_file, "w")
          pid = F.asnumpy(graph.parent_nid)
          for i in range(len(pid)):
              f.write(str(pid[i]) + "\n")
          f.close()
          # Update partition_book
          partition = F.asnumpy(graph.ndata["part_id"])
          for i in range(len(pid)):
              partition_book[pid[i]] = partition[i]
      # Write partition_book.txt
      for part_id in part_dict:
          partition_path = path + str(part_id)
          pb_file = os.path.join(partition_path, "partition_book.txt")
          f = open(pb_file, "w")
          for i in range(len(partition_book)):
              f.write(str(partition_book[i]) + "\n")
          f.close()
      # Write relation_count.txt
      for part_id in part_dict:
          partition_path = path + str(part_id)
          rel_count_file = os.path.join(
              partition_path, "relation_count.txt"
          )
          f = open(rel_count_file, "w")
          f.write(str(total_relations) + "\n")
          f.close()
  
file_path: ogb/examples/lsc/wikikg90m/dgl-ke-ogb-lsc/python/dglke/partition.py
imports: import scipy
  import numpy
  import argparse
  import os
  import dgl
  from dgl import backend
  from dgl.data.utils import load_graphs, save_graphs
  from .dataloader import get_dataset
label_desc: Use image node_id 1 for calling a global function with example usage: write_txt_graph(path, file_name, part_dict, total_nodes, total_relations) without return types