'Performs training steps on episodic input.
Args:
sess: A Tensorflow Session.
x: A list of batches of images defining the episode.
y: A list of batches of labels corresponding to x.
clear_memory: Whether to clear the memory before the episode.
Returns:
List of losses the same length as the episode.'

def episode_step(self, sess, x, y, clear_memory=False):

    outputs = [self.loss, self.gradient_ops]
    if clear_memory:
        self.clear_memory(sess)
    losses = []
    for (xx, yy) in zip(x, y):
        out = sess.run(outputs, feed_dict={self.x: xx, self.y: yy})
        loss = out[0]
        losses.append(loss)
    return losses
