'Sample some episodes and train on some episodes.'

def train(self, sess):

    cur_step = sess.run(self.model.inc_global_step)
    self.cur_step = cur_step
    if (self.cur_step == 0):
        for _ in xrange(100):
            sess.run(self.model.copy_op)
    sess.run(self.model.copy_op)
    (initial_state, observations, actions, rewards, terminated, pads) = self.sample_episodes(sess)
    self.add_to_replay_buffer(initial_state, observations, actions, rewards, terminated, pads)
    (loss, summary) = (0, None)
    if self.use_online_batch:
        (loss, summary) = self._train(sess, observations, initial_state, actions, rewards, terminated, pads)
    if self.update_eps_lambda:
        episode_rewards = np.array(self.episode_rewards)
        episode_lengths = np.array(self.episode_lengths)
        eps_lambda = find_best_eps_lambda(episode_rewards, episode_lengths)
        sess.run(self.model.objective.assign_eps_lambda, feed_dict={self.model.objective.new_eps_lambda: eps_lambda})
    (replay_batch, replay_probs) = self.get_from_replay_buffer(self.replay_batch_size)
    if replay_batch:
        (initial_state, observations, actions, rewards, terminated, pads) = replay_batch
        (loss, summary) = self._train(sess, observations, initial_state, actions, rewards, terminated, pads)
    return (loss, summary, self.total_rewards, self.episode_rewards)
