code: def ppnp_aggr(
      dst_nfeat, neigh_nfeat_list, alpha=0.2, islast=False, r_emb=None
  ):
      dst_indegree, dst_nfeat = dst_nfeat.split(";")
      dst_norm = np.power(int(dst_indegree), -0.5)
      dst_nfeat = [float(item) for item in dst_nfeat.split(" ")]
      dst_nfeat = np.array(dst_nfeat, dtype="float32").reshape(1, -1)
  
      tmp_nfeat_list = []
      tmp_src_indegree = []
      for line in neigh_nfeat_list:
          src_feat_or_dst_feat, r_type, direct = line
          indegree, src_nfeat = src_feat_or_dst_feat.split(";")
          tmp_src_indegree.append(int(indegree))
          # tmp_nfeat_list.append([float(item) for item in src_nfeat.split(' ')])
          src_nfeat_value = [
              float(item) for item in src_nfeat.split(" ")
          ]
          if 0:
              if direct == "1":
                  sign = -1
              elif direct == "0":
                  sign = 1
              else:
                  raise ValueError
              src_nfeat_value = (
                  np.array(src_nfeat_value) + r_emb[int(r_type)] * sign
              )
          else:
              gamma = 10
              hidden_dim = 100
              emb_init = gamma / hidden_dim
              relation = r_emb[int(r_type)]
              phase_rel = relation / (emb_init / np.pi)
              re_rel, im_rel = np.cos(phase_rel), np.sin(phase_rel)
              head = np.array(src_nfeat_value, dtype=np.float16)
              if direct == "1":  # h = t - r
                  re_head, im_head = np.split(head, 2, -1)
                  re_score = re_head * re_rel + im_head * im_rel
                  im_score = -re_head * im_rel + im_head * re_rel
                  src_nfeat_value = np.concatenate(
                      [re_score, im_score], -1
                  )
              elif direct == "0":  # t = h + r
                  re_head, im_head = np.split(head, 2, -1)
                  re_score = re_head * re_rel - im_head * im_rel
                  im_score = re_head * im_rel + im_head * re_rel
                  src_nfeat_value = np.concatenate(
                      [re_score, im_score], -1
                  )
              else:
                  raise ValueError
              # src_nfeat_value = np.array(src_nfeat_value) + r_emb[int(r_type)] * sign
          tmp_nfeat_list.append(src_nfeat_value)
  
      if len(tmp_nfeat_list) > 0:
          neigh_nfeat = np.array(tmp_nfeat_list, dtype="float32")
          aggr_nfeat = np.mean(neigh_nfeat, axis=0)
          new_nfeat = dst_nfeat * alpha + aggr_nfeat * (1 - alpha)
      else:
          new_nfeat = dst_nfeat
  
      new_nfeat = new_nfeat.reshape(
          -1,
      )
      new_nfeat = ["%.7f" % i for i in new_nfeat]
      new_nfeat = " ".join(new_nfeat)
  
      if not islast:
          new_nfeat = dst_indegree + ";" + new_nfeat
      return 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 7 for calling a global function with example usage: ppnp_aggr(dst_nfeat, neigh_nfeat_list, alpha, islast, r_emb) and returns: new_nfeat