code: def merge_edges_and_nfeat(conf, runs):
      """
      Input:
          nid0 \t indegree0 ; nfeat0
          nid1 \t indegree1 ; nfeat1
          src0 \t rela0 \t dst0
          src1 \t rela1 \t dst1
  
      return:
          src \t 0 \t indegree ; nfeat
          src \t runs \t dst0
          src \t runs \t dst1
          src \t runs \t dst2
      """
      for line in sys.stdin:
          fields = line.strip().split("\t")
          if len(fields) == 2:
              # it is node feature
              nid, indegree_nfeat = fields
              sys.stdout.write(
                  "%s\t%s\t%s\n" % (nid, 0, indegree_nfeat)
              )
          else:
              # src, dst = fields
              src, r_type, dst = fields[0], fields[1], fields[2]
              # reverse for join
              sys.stdout.write(
                  "%s\t%s\t%s\t%s\t%s\n" % (src, runs, dst, r_type, 0)
              )
  
              if conf.bidirect:
                  dst, src = src, dst
                  # reverse for join
                  sys.stdout.write(
                      "%s\t%s\t%s\t%s\t%s\n"
                      % (src, runs, dst, r_type, 1)
                  )
  
file_path: PGL/examples/kddcup2021/WikiKG90M/post_smoothing/transe/hadoop_prep.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import absolute_import
  import sys
  import yaml
  from easydict import EasyDict
  import argparse
  import numpy
  import json
  import six
label_desc: Use image node_id 4 for calling a global function with example usage: merge_edges_and_nfeat(conf, runs) without return types