code: def gen(self, init_state=None):
          
          state = init_state or (BEGIN,) * self.state_size
          while True:
              next_word = self.move(state)
              if next_word == END: break
              yield next_word
              state = tuple(state[1:]) + (next_word,)
docs: Starting either with a naive BEGIN state, or the provided `init_state`
          (as a tuple), return a generator that will yield successive items
          until the chain reaches the END state.