'Train the model through the entire dataset once.
Args:
datasets: A dict of data dicts.  The dataset dict is simply a
name(string)-> data dictionary mapping (See top of lfads.py).
batch_size (optional):  The batch_size to use
do_save_ckpt (optional): Should the routine save a checkpoint on this
training epoch?
Returns:
A tuple with 6 float values:
(total cost of the epoch, epoch reconstruction cost,
epoch kl cost, KL weight used this training epoch,
total l2 cost on generator, and the corresponding weight).'

def train_epoch(self, datasets, batch_size=None, do_save_ckpt=True):

    ops_to_eval = [self.cost, self.recon_cost, self.kl_cost, self.kl_weight, self.l2_cost, self.l2_weight, self.train_op]
    collected_op_values = self.run_epoch(datasets, ops_to_eval, kind='train')
    total_cost = total_recon_cost = total_kl_cost = 0.0
    epoch_size = len(collected_op_values)
    for op_values in collected_op_values:
        total_cost += op_values[0]
        total_recon_cost += op_values[1]
        total_kl_cost += op_values[2]
    kl_weight = collected_op_values[(-1)][3]
    l2_cost = collected_op_values[(-1)][4]
    l2_weight = collected_op_values[(-1)][5]
    epoch_total_cost = (total_cost / epoch_size)
    epoch_recon_cost = (total_recon_cost / epoch_size)
    epoch_kl_cost = (total_kl_cost / epoch_size)
    if do_save_ckpt:
        session = tf.get_default_session()
        checkpoint_path = os.path.join(self.hps.lfads_save_dir, (self.hps.checkpoint_name + '.ckpt'))
        self.seso_saver.save(session, checkpoint_path, global_step=self.train_step)
    return (epoch_total_cost, epoch_recon_cost, epoch_kl_cost, kl_weight, l2_cost, l2_weight)
