def shuffled_batches(self, batch_size):
if batch_size >= self.size:<EOL><INDENT>yield self<EOL><DEDENT>else:<EOL><INDENT>batch_splits = math_util.divide_ceiling(self.size, batch_size)<EOL>indices = list(range(self.size))<EOL>np.random.shuffle(indices)<EOL>for sub_indices in np.array_split(indices, batch_splits):<EOL><INDENT>yield Transitions(<EOL>size=len(sub_indices),<EOL>environment_information=None,<EOL>transition_tensors={k: v[sub_indices] for k, v in self.transition_tensors.items()}<EOL>)<EOL><DEDENT><DEDENT>
Generate randomized batches of data