class_docstr: Implemention of Alias-Method
  
  This is an implementation of Alias-Method for sampling efficiently from 
  a discrete probability distribution.
  
  Reference: https://en.wikipedia.org/wiki/Alias_method
  
  Args:
      prob: The discrete probability distribution.
docstr: Sampling.
          
docstr_tok: ["Sampling","."]
code: def sampling(self, n=1):
      """Sampling."""
      x = np.random.rand(n)
      i = np.floor(self.n * x)
      y = self.n * x - i
      i = i.astype(np.int64)
      res = [
          i[k] if y[k] < self.U[i[k]] else self.K[i[k]]
          for k in range(n)
      ]
      if n == 1:
          return res[0]
      else:
          return res
  
file_path: PGL/legacy/examples/line/data_loader.py
imports: import os
  import io
  import sys
  import numpy
  from pgl import graph
  from pgl.utils.logger import log
label_desc: Use image node_id 2 for calling the AliasSampling obj's underlying member method code with example usage: obj.sampling(n) and returns: res, res