class_docstr: Implementation of Walker's alias method.
  
  This method generates a random sample from given probabilities
  :math:`p_1, \dots, p_n` in :math:`O(1)` time.
  It is more efficient than :func:`~numpy.random.choice`.
  This class works on both CPU and GPU.
  
  Args:
      probs (float list): Probabilities of entries. They are normalized with
                          `sum(probs)`.
  
  See: `Wikipedia article <https://en.wikipedia.org/wiki/Alias_method>`_
code: def sample_xp(self, xp, shape):
      thr_dtype = self.threshold.dtype
      pb = xp.random.uniform(0, len(self.threshold), shape)
      index = pb.astype(numpy.int32)
      left_right = self.threshold[index] < (
          pb.astype(thr_dtype) - index.astype(thr_dtype)
      )
      left_right = left_right.astype(numpy.int32)
      return self.values[index * 2 + left_right]
  
file_path: chainer/chainer/utils/walker_alias.py
imports: import numpy
  import chainer
  from chainer.backends import cuda
  from chainer import device_resident
label_desc: Use image node_id 5 for calling the WalkerAlias obj's underlying member method code with example usage: obj.sample_xp(xp, shape) and returns: self