class_docstr: A shrinker is a child object of a ConjectureRunner which is designed to
  manage the associated state of a particular shrink problem. That is, we
  have some initial ConjectureData object and some property of interest
  that it satisfies, and we want to find a ConjectureData object with a
  shortlex (see sort_key above) smaller buffer that exhibits the same
  property.
  
  Currently the only property of interest we use is that the status is
  INTERESTING and the interesting_origin takes on some fixed value, but we
  may potentially be interested in other use cases later.
  However we assume that data with a status < VALID never satisfies the predicate.
  
  The shrinker keeps track of a value shrink_target which represents the
  current best known ConjectureData object satisfying the predicate.
  It refines this value by repeatedly running *shrink passes*, which are
  methods that perform a series of transformations to the current shrink_target
  and evaluate the underlying test function to find new ConjectureData
  objects. If any of these satisfy the predicate, the shrink_target
  is updated automatically. Shrinking runs until no shrink pass can
  improve the shrink_target, at which point it stops. It may also be
  terminated if the underlying engine throws RunIsComplete, but that
  is handled by the calling code rather than the Shrinker.
  
  =======================
  Designing Shrink Passes
  =======================
  
  Generally a shrink pass is just any function that calls
  cached_test_function and/or incorporate_new_buffer a number of times,
  but there are a couple of useful things to bear in mind.
  
  A shrink pass *makes progress* if running it changes self.shrink_target
  (i.e. it tries a shortlex smaller ConjectureData object satisfying
  the predicate). The desired end state of shrinking is to find a
  value such that no shrink pass can make progress, i.e. that we
  are at a local minimum for each shrink pass.
  
  In aid of this goal, the main invariant that a shrink pass much
  satisfy is that whether it makes progress must be deterministic.
  It is fine (encouraged even) for the specific progress it makes
  to be non-deterministic, but if you run a shrink pass, it makes
  no progress, and then you immediately run it again, it should
  never succeed on the second time. This allows us to stop as soon
  as we have run each shrink pass and seen no progress on any of
  them.
  
  This means that e.g. it's fine to try each of N deletions
  or replacements in a random order, but it's not OK to try N random
  deletions (unless you have already shrunk at least once, though we
  don't currently take advantage of this loophole).
  
  Shrink passes need to be written so as to be robust against
  change in the underlying shrink target. It is generally safe
  to assume that the shrink target does not change prior to the
  point of first modification - e.g. if you change no bytes at
  index ``i``, all examples whose start is ``<= i`` still exist,
  as do all blocks, and the data object is still of length
  ``>= i + 1``. This can only be violated by bad user code which
  relies on an external source of non-determinism.
  
  When the underlying shrink_target changes, shrink
  passes should not run substantially more test_function calls
  on success than they do on failure. Say, no more than a constant
  factor more. In particular shrink passes should not iterate to a
  fixed point.
  
  This means that shrink passes are often written with loops that
  are carefully designed to do the right thing in the case that no
  shrinks occurred and try to adapt to any changes to do a reasonable
  job. e.g. say we wanted to write a shrink pass that tried deleting
  each individual byte (this isn't an especially good choice,
  but it leads to a simple illustrative example), we might do it
  by iterating over the buffer like so:
  
  .. code-block:: python
  
      i = 0
      while i < len(self.shrink_target.buffer):
          if not self.incorporate_new_buffer(
              self.shrink_target.buffer[:i] + self.shrink_target.buffer[i + 1 :]
          ):
              i += 1
  
  The reason for writing the loop this way is that i is always a
  valid index into the current buffer, even if the current buffer
  changes as a result of our actions. When the buffer changes,
  we leave the index where it is rather than restarting from the
  beginning, and carry on. This means that the number of steps we
  run in this case is always bounded above by the number of steps
  we would run if nothing works.
  
  Another thing to bear in mind about shrink pass design is that
  they should prioritise *progress*. If you have N operations that
  you need to run, you should try to order them in such a way as
  to avoid stalling, where you have long periods of test function
  invocations where no shrinks happen. This is bad because whenever
  we shrink we reduce the amount of work the shrinker has to do
  in future, and often speed up the test function, so we ideally
  wanted those shrinks to happen much earlier in the process.
  
  Sometimes stalls are inevitable of course - e.g. if the pass
  makes no progress, then the entire thing is just one long stall,
  but it's helpful to design it so that stalls are less likely
  in typical behaviour.
  
  The two easiest ways to do this are:
  
  * Just run the N steps in random order. As long as a
    reasonably large proportion of the operations succeed, this
    guarantees the expected stall length is quite short. The
    book keeping for making sure this does the right thing when
    it succeeds can be quite annoying.
  * When you have any sort of nested loop, loop in such a way
    that both loop variables change each time. This prevents
    stalls which occur when one particular value for the outer
    loop is impossible to make progress on, rendering the entire
    inner loop into a stall.
  
  However, although progress is good, too much progress can be
  a bad sign! If you're *only* seeing successful reductions,
  that's probably a sign that you are making changes that are
  too timid. Two useful things to offset this:
  
  * It's worth writing shrink passes which are *adaptive*, in
    the sense that when operations seem to be working really
    well we try to bundle multiple of them together. This can
    often be used to turn what would be O(m) successful calls
    into O(log(m)).
  * It's often worth trying one or two special minimal values
    before trying anything more fine grained (e.g. replacing
    the whole thing with zero).
class_docstr_tok: ["A","shrinker","is","a","child","object","of","a","ConjectureRunner","which","is","designed","to","manage","the","associated","state","of","a","particular","shrink","problem",".","That","is",",","we","have","some","initial","ConjectureData","object","and","some","property","of","interest","that","it","satisfies",",","and","we","want","to","find","a","ConjectureData","object","with","a","shortlex","(","see","sort_key","above",")","smaller","buffer","that","exhibits","the","same","property",".","Currently","the","only","property","of","interest","we","use","is","that","the","status","is","INTERESTING","and","the","interesting_origin","takes","on","some","fixed","value",",","but","we","may","potentially","be","interested","in","other","use","cases","later",".","However","we","assume","that","data","with","a","status","<","VALID","never","satisfies","the","predicate",".","The","shrinker","keeps","track","of","a","value","shrink_target","which","represents","the","current","best","known","ConjectureData","object","satisfying","the","predicate",".","It","refines","this","value","by","repeatedly","running","*","shrink","passes","*",",","which","are","methods","that","perform","a","series","of","transformations","to","the","current","shrink_target","and","evaluate","the","underlying","test","function","to","find","new","ConjectureData","objects",".","If","any","of","these","satisfy","the","predicate",",","the","shrink_target","is","updated","automatically",".","Shrinking","runs","until","no","shrink","pass","can","improve","the","shrink_target",",","at","which","point","it","stops",".","It","may","also","be","terminated","if","the","underlying","engine","throws","RunIsComplete",",","but","that","is","handled","by","the","calling","code","rather","than","the","Shrinker",".","=======================","Designing","Shrink","Passes","=======================","Generally","a","shrink","pass","is","just","any","function","that","calls","cached_test_function","and\/or","incorporate_new_buffer","a","number","of","times",",","but","there","are","a","couple","of","useful","things","to","bear","in","mind",".","A","shrink","pass","*","makes","progress","*","if","running","it","changes","self.shrink_target","(","i.e",".","it","tries","a","shortlex","smaller","ConjectureData","object","satisfying","the","predicate",")",".","The","desired","end","state","of","shrinking","is","to","find","a","value","such","that","no","shrink","pass","can","make","progress",",","i.e",".","that","we","are","at","a","local","minimum","for","each","shrink","pass",".","In","aid","of","this","goal",",","the","main","invariant","that","a","shrink","pass","much","satisfy","is","that","whether","it","makes","progress","must","be","deterministic",".","It","is","fine","(","encouraged","even",")","for","the","specific","progress","it","makes","to","be","non-deterministic",",","but","if","you","run","a","shrink","pass",",","it","makes","no","progress",",","and","then","you","immediately","run","it","again",",","it","should","never","succeed","on","the","second","time",".","This","allows","us","to","stop","as","soon","as","we","have","run","each","shrink","pass","and","seen","no","progress","on","any","of","them",".","This","means","that","e.g",".","it","'s","fine","to","try","each","of","N","deletions","or","replacements","in","a","random","order",",","but","it","'s","not","OK","to","try","N","random","deletions","(","unless","you","have","already","shrunk","at","least","once",",","though","we","do","n't","currently","take","advantage","of","this","loophole",")",".","Shrink","passes","need","to","be","written","so","as","to","be","robust","against","change","in","the","underlying","shrink","target",".","It","is","generally","safe","to","assume","that","the","shrink","target","does","not","change","prior","to","the","point","of","first","modification","-","e.g",".","if","you","change","no","bytes","at","index","``","i","``",",","all","examples","whose","start","is","``","<","=","i","``","still","exist",",","as","do","all","blocks",",","and","the","data","object","is","still","of","length","``",">","=","i","+","1","``",".","This","can","only","be","violated","by","bad","user","code","which","relies","on","an","external","source","of","non-determinism",".","When","the","underlying","shrink_target","changes",",","shrink","passes","should","not","run","substantially","more","test_function","calls","on","success","than","they","do","on","failure",".","Say",",","no","more","than","a","constant","factor","more",".","In","particular","shrink","passes","should","not","iterate","to","a","fixed","point",".","This","means","that","shrink","passes","are","often","written","with","loops","that","are","carefully","designed","to","do","the","right","thing","in","the","case","that","no","shrinks","occurred","and","try","to","adapt","to","any","changes","to","do","a","reasonable","job",".","e.g",".","say","we","wanted","to","write","a","shrink","pass","that","tried","deleting","each","individual","byte","(","this","is","n't","an","especially","good","choice",",","but","it","leads","to","a","simple","illustrative","example",")",",","we","might","do","it","by","iterating","over","the","buffer","like","so",":","..","code-block",":",":","python","i","=","0","while","i","<","len","(","self.shrink_target.buffer",")",":","if","not","self.incorporate_new_buffer","(","self.shrink_target.buffer","[",":","i","]","+","self.shrink_target.buffer","[","i","+","1",":","]",")",":","i","+=","1","The","reason","for","writing","the","loop","this","way","is","that","i","is","always","a","valid","index","into","the","current","buffer",",","even","if","the","current","buffer","changes","as","a","result","of","our","actions",".","When","the","buffer","changes",",","we","leave","the","index","where","it","is","rather","than","restarting","from","the","beginning",",","and","carry","on",".","This","means","that","the","number","of","steps","we","run","in","this","case","is","always","bounded","above","by","the","number","of","steps","we","would","run","if","nothing","works",".","Another","thing","to","bear","in","mind","about","shrink","pass","design","is","that","they","should","prioritise","*","progress","*",".","If","you","have","N","operations","that","you","need","to","run",",","you","should","try","to","order","them","in","such","a","way","as","to","avoid","stalling",",","where","you","have","long","periods","of","test","function","invocations","where","no","shrinks","happen",".","This","is","bad","because","whenever","we","shrink","we","reduce","the","amount","of","work","the","shrinker","has","to","do","in","future",",","and","often","speed","up","the","test","function",",","so","we","ideally","wanted","those","shrinks","to","happen","much","earlier","in","the","process",".","Sometimes","stalls","are","inevitable","of","course","-","e.g",".","if","the","pass","makes","no","progress",",","then","the","entire","thing","is","just","one","long","stall",",","but","it","'s","helpful","to","design","it","so","that","stalls","are","less","likely","in","typical","behaviour",".","The","two","easiest","ways","to","do","this","are",":","*","Just","run","the","N","steps","in","random","order",".","As","long","as","a","reasonably","large","proportion","of","the","operations","succeed",",","this","guarantees","the","expected","stall","length","is","quite","short",".","The","book","keeping","for","making","sure","this","does","the","right","thing","when","it","succeeds","can","be","quite","annoying",".","*","When","you","have","any","sort","of","nested","loop",",","loop","in","such","a","way","that","both","loop","variables","change","each","time",".","This","prevents","stalls","which","occur","when","one","particular","value","for","the","outer","loop","is","impossible","to","make","progress","on",",","rendering","the","entire","inner","loop","into","a","stall",".","However",",","although","progress","is","good",",","too","much","progress","can","be","a","bad","sign","!","If","you","'re","*","only","*","seeing","successful","reductions",",","that","'s","probably","a","sign","that","you","are","making","changes","that","are","too","timid",".","Two","useful","things","to","offset","this",":","*","It","'s","worth","writing","shrink","passes","which","are","*","adaptive","*",",","in","the","sense","that","when","operations","seem","to","be","working","really","well","we","try","to","bundle","multiple","of","them","together",".","This","can","often","be","used","to","turn","what","would","be","O","(","m",")","successful","calls","into","O","(","log","(","m",")",")",".","*","It","'s","often","worth","trying","one","or","two","special","minimal","values","before","trying","anything","more","fine","grained","(","e.g",".","replacing","the","whole","thing","with","zero",")","."]
code: def examples(self):
      return self.shrink_target.examples
  
imports: from collections import defaultdict
  from typing import TYPE_CHECKING, Callable, Dict, Optional
  import attr
  from hypothesis.internal.compat import int_from_bytes, int_to_bytes
  from hypothesis.internal.conjecture.choicetree import ChoiceTree, prefix_selection_order, random_selection_order
  from hypothesis.internal.conjecture.data import DRAW_FLOAT_LABEL, ConjectureData, ConjectureResult, Status
  from hypothesis.internal.conjecture.dfa import ConcreteDFA
  from hypothesis.internal.conjecture.floats import float_to_lex, lex_to_float
  from hypothesis.internal.conjecture.junkdrawer import binary_search, find_integer, replace_all
  from hypothesis.internal.conjecture.shrinking import Float, Integer, Lexical, Ordering
  from hypothesis.internal.conjecture.shrinking.learned_dfas import SHRINKING_DFAS
label_desc: Use image node_id 23 for calling the Shrinker obj's underlying member method code with example usage: obj.examples() and returns: self