class_docstr: Sampler based on Vose's algorithm for the alias method. See
  http://www.keithschwarz.com/darts-dice-coins/ for a good explanation.
  
  The general idea is that we store a table of triples (base, alternate, p).
  base. We then pick a triple uniformly at random, and choose its alternate
  value with probability p and else choose its base value. The triples are
  chosen so that the resulting mixture has the right distribution.
  
  We maintain the following invariants to try to produce good shrinks:
  
  1. The table is in lexicographic (base, alternate) order, so that choosing
     an earlier value in the list always lowers (or at least leaves
     unchanged) the value.
  2. base[i] < alternate[i], so that shrinking the draw always results in
     shrinking the chosen element.
class_docstr_tok: ["Sampler","based","on","Vose","'s","algorithm","for","the","alias","method",".","See","http",":","\/\/www.keithschwarz.com\/darts-dice-coins\/","for","a","good","explanation",".","The","general","idea","is","that","we","store","a","table","of","triples","(","base",",","alternate",",","p",")",".","base",".","We","then","pick","a","triple","uniformly","at","random",",","and","choose","its","alternate","value","with","probability","p","and","else","choose","its","base","value",".","The","triples","are","chosen","so","that","the","resulting","mixture","has","the","right","distribution",".","We","maintain","the","following","invariants","to","try","to","produce","good","shrinks",":","1",".","The","table","is","in","lexicographic","(","base",",","alternate",")","order",",","so","that","choosing","an","earlier","value","in","the","list","always","lowers","(","or","at","least","leaves","unchanged",")","the","value",".","2.","base","[","i","]","<","alternate","[","i","]",",","so","that","shrinking","the","draw","always","results","in","shrinking","the","chosen","element","."]
code: def sample(self, data):
      data.start_example(SAMPLE_IN_SAMPLER_LABLE)
      i = integer_range(data, 0, len(self.table) - 1)
      base, alternate, alternate_chance = self.table[i]
      use_alternate = biased_coin(data, alternate_chance)
      data.stop_example()
      if use_alternate:
          return alternate
      else:
          return base
  
imports: from __future__ import absolute_import, division, print_function
  import enum
  import hashlib
  import heapq
  import sys
  from collections import OrderedDict
  from fractions import Fraction
  from hypothesis.errors import InvalidArgument
  from hypothesis.internal.compat import abc, bit_length, floor, hrange, int_from_bytes, qualname, str_to_bytes
  from hypothesis.internal.floats import int_to_float
label_desc: Use image node_id 2 for calling the Sampler obj's underlying member method code with example usage: obj.sample(data) and returns: alternate, base