code: def alias_setup(probs):
      """
      Compute utility lists for non-uniform sampling from discrete distributions.
      Refer to https://hips.seas.harvard.edu/blog/2013/03/03/the-alias-method-efficient-sampling-with-many-discrete-outcomes/
      for details
      """
      K = len(probs)
      q = np.zeros(K, dtype=np.float32)
      J = np.zeros(K, dtype=np.int32)
  
      smaller = []
      larger = []
      for kk, prob in enumerate(probs):
          q[kk] = K * prob
          if q[kk] < 1.0:
              smaller.append(kk)
          else:
              larger.append(kk)
  
      while len(smaller) > 0 and len(larger) > 0:
          small = smaller.pop()
          large = larger.pop()
  
          J[small] = large
          q[large] = q[large] + q[small] - 1.0
          if q[large] < 1.0:
              smaller.append(large)
          else:
              larger.append(large)
  
      return J, q
  
file_path: OpenNE/src/openne/walker.py
imports: from __future__ import print_function
  import random
  import numpy
  import multiprocessing
label_desc: Use image node_id 2 for calling a global function with example usage: alias_setup(probs) and returns: J,  q