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: "ConjectureData", forced: Optional[int] = None
  ) -> int:
      data.start_example(SAMPLE_IN_SAMPLER_LABEL)
      forced_choice = (  # pragma: no branch # https://github.com/nedbat/coveragepy/issues/1617
          None
          if forced is None
          else next(
              (b, a, a_c)
              for (b, a, a_c) in self.table
              if forced in (b, a)
          )
      )
      base, alternate, alternate_chance = choice(
          data, self.table, forced=forced_choice
      )
      use_alternate = data.draw_boolean(
          alternate_chance,
          forced=None if forced is None else forced == alternate,
      )
      data.stop_example()
      if use_alternate:
          assert forced is None or alternate == forced, (
              forced,
              alternate,
          )
          return alternate
      else:
          assert forced is None or base == forced, (forced, base)
          return base
  
imports: import enum
  import hashlib
  import heapq
  import sys
  from collections import OrderedDict, abc
  from functools import lru_cache
  from typing import TYPE_CHECKING, List, Optional, Sequence, Tuple, Type, TypeVar, Union
  from hypothesis.errors import InvalidArgument
  from hypothesis.internal.compat import int_from_bytes
  from hypothesis.internal.floats import next_up
label_desc: Use image node_id 2 for calling the Sampler obj's underlying member method code with example usage: obj.sample(data, forced) and returns: alternate, base