code: def block_program(description):
      """Mini-DSL for block rewriting. A sequence of commands that will be run
      over all contiguous sequences of blocks of the description length in order.
      Commands are:
  
          * ".", keep this block unchanged
          * "-", subtract one from this block.
          * "0", replace this block with zero
          * "X", delete this block
  
      If a command does not apply (currently only because it's - on a zero
      block) the block will be silently skipped over. As a side effect of
      running a block program its score will be updated.
      """
      name = "block_program(%r)" % (description,)
  
      if name not in SHRINK_PASS_DEFINITIONS:
          """Defines a shrink pass that runs the block program ``description``
          at every block index."""
          n = len(description)
  
          def run(self, chooser):
              """Adaptively attempt to run the block program at the current
              index. If this successfully applies the block program ``k`` times
              then this runs in ``O(log(k))`` test function calls."""
              i = chooser.choose(
                  hrange(len(self.shrink_target.blocks) - n)
              )
              # First, run the block program at the chosen index. If this fails,
              # don't do any extra work, so that failure is as cheap as possible.
              if not self.run_block_program(
                  i, description, original=self.shrink_target
              ):
                  return
  
              # Because we run in a random order we will often find ourselves in the middle
              # of a region where we could run the block program. We thus start by moving
              # left to the beginning of that region if possible in order to to start from
              # the beginning of that region.
              def offset_left(k):
                  return i - k * n
  
              i = offset_left(
                  find_integer(
                      lambda k: self.run_block_program(
                          offset_left(k),
                          description,
                          original=self.shrink_target,
                      )
                  )
              )
  
              original = self.shrink_target
  
              # Now try to run the block program multiple times here.
              find_integer(
                  lambda k: self.run_block_program(
                      i, description, original=original, repeats=k
                  )
              )
  
          run.__name__ = name
  
          defines_shrink_pass()(run)
          assert name in SHRINK_PASS_DEFINITIONS
      return name
  
imports: from __future__ import absolute_import, division, print_function
  from collections import defaultdict
  import attr
  from hypothesis.internal.compat import hbytes, hrange, int_from_bytes, int_to_bytes
  from hypothesis.internal.conjecture.choicetree import ChoiceTree
  from hypothesis.internal.conjecture.data import ConjectureResult, Overrun, Status
  from hypothesis.internal.conjecture.floats import DRAW_FLOAT_LABEL, float_to_lex, lex_to_float
  from hypothesis.internal.conjecture.junkdrawer import binary_search, replace_all
  from hypothesis.internal.conjecture.shrinking import Float, Integer, Lexical, Ordering
  from hypothesis.internal.conjecture.shrinking.common import find_integer
label_desc: Use image node_id 3 for calling a global function with example usage: block_program(description) and returns: name, unknown