class_docstr: :class:`AbstractSampler` is a abstract class, all sampler should inherit from it. This sampler supports returning
  a certain number of random value_ids according to the input key_id, and it also supports to prohibit
  certain key-value pairs by setting used_ids.
  
  Args:
      distribution (str): The string of distribution, which is used for subclass.
  
  Attributes:
      used_ids (numpy.ndarray): The result of :meth:`get_used_ids`.
class_docstr_tok: [":","class",":","`","AbstractSampler","`","is","a","abstract","class",",","all","sampler","should","inherit","from","it",".","This","sampler","supports","returning","a","certain","number","of","random","value_ids","according","to","the","input","key_id",",","and","it","also","supports","to","prohibit","certain","key-value","pairs","by","setting","used_ids",".","Args",":","distribution","(","str",")",":","The","string","of","distribution",",","which","is","used","for","subclass",".","Attributes",":","used_ids","(","numpy.ndarray",")",":","The","result","of",":","meth",":","`","get_used_ids","`","."]
docstr: Build alias table for popularity_biased sampling.
docstr_tok: ["Build","alias","table","for","popularity_biased","sampling","."]
code: def _build_alias_table(self):
      """Build alias table for popularity_biased sampling."""
      candidates_list = self._get_candidates_list()
      self.prob = dict(Counter(candidates_list))
      self.alias = self.prob.copy()
      large_q = []
      small_q = []
      for i in self.prob:
          self.alias[i] = -1
          self.prob[i] = self.prob[i] / len(candidates_list)
          self.prob[i] = pow(self.prob[i], self.alpha)
      normalize_count = sum(self.prob.values())
      for i in self.prob:
          self.prob[i] = self.prob[i] / normalize_count * len(self.prob)
          if self.prob[i] > 1:
              large_q.append(i)
          elif self.prob[i] < 1:
              small_q.append(i)
      while len(large_q) != 0 and len(small_q) != 0:
          l = large_q.pop(0)
          s = small_q.pop(0)
          self.alias[s] = l
          self.prob[l] = self.prob[l] - (1 - self.prob[s])
          if self.prob[l] < 1:
              small_q.append(l)
          elif self.prob[l] > 1:
              large_q.append(l)
  
imports: import copy
  import numpy
  from numpy.random import sample
  import torch
  from collections import Counter
label_desc: Use image node_id 5 for calling the AbstractSampler obj's underlying member method code with example usage: obj._build_alias_table() without return types