class_docstr: A fast way to sample from a multinomial distribution.
  Faster than torch.multinomial or np.multinomial.
  The setup (__init__) for this class is slow, however
  `draw' (actual sampling) is fast.
class_docstr_tok: ["A","fast","way","to","sample","from","a","multinomial","distribution",".","Faster","than","torch.multinomial","or","np.multinomial",".","The","setup","(","__init__",")","for","this","class","is","slow",",","however","`","draw","'","(","actual","sampling",")","is","fast","."]
docstr: Draw N samples from multinomial
  :param N: number of samples
  :return: samples
docstr_tok: ["Draw","N","samples","from","multinomial",":","param","N",":","number","of","samples",":","return",":","samples"]
code: def draw(self, N):
      """
      Draw N samples from multinomial
      :param N: number of samples
      :return: samples
      """
      K = self.alias.size(0)
  
      kk = torch.zeros(
          N, dtype=torch.long, device=self.prob.device
      ).random_(0, K)
      prob = self.prob.index_select(0, kk)
      alias = self.alias.index_select(0, kk)
      # b is whether a random number is greater than q
      b = torch.bernoulli(prob)
      oq = kk.mul(b.long())
      oj = alias.mul((1 - b).long())
  
      return oq + oj
  
imports: import logging
  import math
  import pprint
  from typing import List, Union
  import numpy
  import torch
  from classy_vision.generic.distributed_util import all_reduce_mean, gather_from_all, get_rank
  from classy_vision.generic.util import is_pos_int
  from classy_vision.losses import ClassyLoss, register_loss
  from torch import nn
  from vissl.config import AttrDict
label_desc: Use image node_id 2 for calling the AliasMethod obj's underlying member method code with example usage: obj.draw(N) and returns: unknown