import tensorflow as tf

        with tf.control_dependencies([tf.assert_less_equal(num_instances, self.capacity)]):
            indices = tf.range(self.memory_index, self.memory_index + num_instances) % self.capacity
