code: def generate_replies(self, max_length, state_size, reply_to, dataset):
          
          state_sets = self.get_reply_states(
              reply_to,
              dataset + state_size_dataset(state_size)
          )
  
          if not state_sets:
              yield from self.generate_cont(max_length, state_size,
                                            None, False, dataset)
              return
  
          random.shuffle(state_sets)
  
          generate = lambda state, backward: self.generate(
              state_size, state,
              dataset, backward
          )
  
          for states in cycle(state_sets):
              state = random.choice(states)
              parts = chain(
                  reversed(list(generate(state, True))),
                  (state,),
                  generate(state, False)
              )
              parts = islice(parts, 0, max_length)
              yield self.format(parts)
docs: Generate replies.
  
          Parameters
          ----------
          max_length : `int` or `None`
              Maximum sentence length.
          state_size : `int`
              State size.
          reply_to : `str`
              Input string.
          dataset: `str`
              Dataset key prefix.
  
          Returns
          -------
          `generator` of `str`
              Generated texts.