code: def get_indegree_reducer(conf):
      """
      get indegree of every node
  
      Input:
          dst0 \t 0 \t nfeat
          dst0 \t 1 \t src0
          dst0 \t 1 \t src1
          dst0 \t 1 \t src2
  
      Output:
          dst0 \t indegree0 ; nfeat0
          dst1 \t indegree1 ; nfeat1
      """
      cur_dst = None
      cur_nfeat = None
      indegree = 0  # for self loop
      for line in sys.stdin:
          nid, mode, nid_or_nfeat = line.strip().split("\t")
          mode = int(mode)
          if mode == 0:
              if cur_dst is not None:
                  if indegree == 0:
                      indegree = 1
                  sys.stdout.write(
                      "%s\t%s;%s\n" % (cur_dst, indegree, cur_nfeat)
                  )
  
              cur_dst = nid
              cur_nfeat = nid_or_nfeat
              indegree = 0
  
          else:
              indegree += 1
  
      if indegree == 0:
          indegree = 1
      sys.stdout.write("%s\t%s;%s\n" % (cur_dst, indegree, cur_nfeat))
  
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 3 for calling a global function with example usage: get_indegree_reducer(conf) without return types