code: def reduce_neigh(conf, runs):
      """
      Input:
          dst(nid) \t 0 \t dst_indegree ; dst_nfeat
          dst0 \t runs \t src_indegree ; src_nfeat \t rela0 \t direct0
          dst0 \t runs \t src_indegree ; src_nfeat \t rela1 \t direct1
          dst0 \t runs \t src_indegree ; src_nfeat \t rela2 \t direct2
  
      Output:
          dst0 \t dst_indegree ; new_feat
          dst1 \t dst_indegree ; new_feat
      """
      islast = conf.khop == runs  # if True, means the last hop
      cur_dst = None
      cur_dst_nfeat = None
      neigh_nfeat_list = []
      r_emb = np.load("wikikg90m_TransE_l2_relation.npy")
      last_dst = None
      for line in sys.stdin:
          # dst, mode, src_feat_or_dst_feat = line.strip().split('\t')
          fields = line.strip().split("\t")
          dst, mode, src_feat_or_dst_feat = (
              fields[0],
              fields[1],
              fields[2],
          )
  
          if last_dst is not None and last_dst != dst:
              new_nfeat = ppnp_aggr(
                  cur_dst_nfeat,
                  neigh_nfeat_list,
                  conf.alpha,
                  islast,
                  r_emb,
              )
              sys.stdout.write("%s\t%s\n" % (cur_dst, new_nfeat))
              neigh_nfeat_list = []
  
          mode = int(mode)
          if mode == 0:
              cur_dst = dst
              cur_dst_nfeat = src_feat_or_dst_feat
          else:
              if len(neigh_nfeat_list) < 50000:
                  r_type = fields[3]
                  direct = fields[4]
                  neigh_nfeat_list.append(
                      [src_feat_or_dst_feat, r_type, direct]
                  )
  
          last_dst = dst
  
          # mode = int(mode)
          # if mode == 0:
      # if cur_dst is not None and cur_dst_nfeat is not None: # not the first line
      # new_nfeat = ppnp_aggr(cur_dst_nfeat, neigh_nfeat_list, conf.alpha, islast, r_emb)
      # sys.stdout.write("%s\t%s\n" % (cur_dst, new_nfeat))
  
      # cur_dst = dst
      # cur_dst_nfeat = src_feat_or_dst_feat
      # neigh_nfeat_list = []
  
      # else:
      # r_type = fields[3]
      # direct = fields[4]
      # neigh_nfeat_list.append([src_feat_or_dst_feat, r_type, direct])
  
      if cur_dst_nfeat is not None:
          new_nfeat = ppnp_aggr(
              cur_dst_nfeat, neigh_nfeat_list, conf.alpha, islast, r_emb
          )
          sys.stdout.write("%s\t%s\n" % (cur_dst, new_nfeat))
  
file_path: PGL/examples/kddcup2021/WikiKG90M/post_smoothing/rotate/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 6 for calling a global function with example usage: reduce_neigh(conf, runs) without return types