code: def alias_sample(size, alias, events):
      """Implement of alias sample.
      Args:
          size: Output shape.
          alias: The alias table build by `alias_sample_build_table`.
          events: The events table build by `alias_sample_build_table`.
  
      Return:
          samples: The generated random samples.
      """
      rand_num = np.random.uniform(0.0, len(alias), size)
      idx = rand_num.astype("int64")
      uni = rand_num - idx
      flags = uni >= alias[idx]
      idx[flags] = events[idx][flags]
      return idx
  
file_path: PGL/legacy/pgl/sample.py
imports: import time
  import copy
  import numpy
  import pgl
  from pgl.utils.logger import log
  from pgl import graph_kernel
label_desc: Use image node_id 5 for calling a global function with example usage: alias_sample(size, alias, events) and returns: idx