def split_shuffled_batches(self, batch_size: int, complete_rollouts: Optional[bool]=False):
    '\n        Batch generation. Split the step collection into random mini-batches of size batch_size.\n\n        :param batch_size: number of steps per batch\n        :param complete_rollouts: if `complete_rollouts = True`, the batches will not contain partial rollouts.\n                                  However, the size of the returned batches cannot be strictly maintained in this case.\n\n        .. note::\n            This method is also supposed to be called for recurrent networks, which have a different `evaluate()`\n            method that recognized where the rollouts end within a batch.\n        '
    if (batch_size >= self.length):
        (yield self)
    elif (complete_rollouts and self.continuous):
        rollout_lengths = self.rollout_lengths
        shuffled_idcs = random.sample(range(len(rollout_lengths)), len(rollout_lengths))
        batch = []
        cur_batch_size = 0
        for idx in shuffled_idcs:
            batch.append(idx)
            cur_batch_size += rollout_lengths[idx]
            if (cur_batch_size >= batch_size):
                (yield self.get_rollout(batch))
                batch.clear()
                cur_batch_size = 0
        if batch:
            (yield self.get_rollout(batch))
    else:
        for b in gen_shuffled_batch_idcs(batch_size, self.length):
            (yield self[b])
Batch generation. Split the step collection into random mini-batches of size batch_size.

:param batch_size: number of steps per batch
:param complete_rollouts: if `complete_rollouts = True`, the batches will not contain partial rollouts.
                          However, the size of the returned batches cannot be strictly maintained in this case.

.. note::
    This method is also supposed to be called for recurrent networks, which have a different `evaluate()`
    method that recognized where the rollouts end within a batch.
def split_shuffled_batches(self, batch_size: int, complete_rollouts: Optional[bool]=False):
    '\n        Batch generation. Split the step collection into random mini-batches of size batch_size.\n\n        :param batch_size: number of steps per batch\n        :param complete_rollouts: if `complete_rollouts = True`, the batches will not contain partial rollouts.\n                                  However, the size of the returned batches cannot be strictly maintained in this case.\n\n        .. note::\n            This method is also supposed to be called for recurrent networks, which have a different `evaluate()`\n            method that recognized where the rollouts end within a batch.\n        '
    if (batch_size >= self.length):
        (yield self)
    elif (complete_rollouts and self.continuous):
        rollout_lengths = self.rollout_lengths
        shuffled_idcs = random.sample(range(len(rollout_lengths)), len(rollout_lengths))
        batch = []
        cur_batch_size = 0
        for idx in shuffled_idcs:
            batch.append(idx)
            cur_batch_size += rollout_lengths[idx]
            if (cur_batch_size >= batch_size):
                (yield self.get_rollout(batch))
                batch.clear()
                cur_batch_size = 0
        if batch:
            (yield self.get_rollout(batch))
    else:
        for b in gen_shuffled_batch_idcs(batch_size, self.length):
            (yield self[b])