'Plot and summarize stuff in tensorboard.
Note that everything done in the current function is otherwise done on
a single, randomly selected dataset (except for summary_values, which are
passed in.)
Args:
datasets, the dictionary of datasets used in the study.
summary_values:  These summary values are created from the training loop,
and so summarize the entire set of datasets.'

def summarize_all(self, datasets, summary_values):

    hps = self.hps
    tr_kl_cost = summary_values['tr_kl_cost']
    tr_recon_cost = summary_values['tr_recon_cost']
    tr_total_cost = summary_values['tr_total_cost']
    kl_weight = summary_values['kl_weight']
    l2_weight = summary_values['l2_weight']
    l2_cost = summary_values['l2_cost']
    has_any_valid_set = summary_values['has_any_valid_set']
    i = summary_values['nepochs']
    session = tf.get_default_session()
    (train_summ, train_step) = session.run([self.merged_train, self.train_step], feed_dict={self.l2_cost_ph: l2_cost, self.kl_cost_ph: tr_kl_cost, self.recon_cost_ph: tr_recon_cost, self.total_cost_ph: tr_total_cost})
    self.writer.add_summary(train_summ, train_step)
    if has_any_valid_set:
        ev_kl_cost = summary_values['ev_kl_cost']
        ev_recon_cost = summary_values['ev_recon_cost']
        ev_total_cost = summary_values['ev_total_cost']
        eval_summ = session.run(self.merged_valid, feed_dict={self.kl_cost_ph: ev_kl_cost, self.recon_cost_ph: ev_recon_cost, self.total_cost_ph: ev_total_cost})
        self.writer.add_summary(eval_summ, train_step)
        print(('Epoch:%d,    step:%d    (TRAIN,    VALID):    total:    %.2f,    %.2f                        recon:    %.2f,    %.2f,                    kl:    %.2f,    %.2f,                    l2:    %.5f,                        kl    weight:    %.2f,    l2    weight:    %.2f' % (i, train_step, tr_total_cost, ev_total_cost, tr_recon_cost, ev_recon_cost, tr_kl_cost, ev_kl_cost, l2_cost, kl_weight, l2_weight)))
        csv_outstr = ('epoch,%d,    step,%d,    total,%.2f,%.2f,                            recon,%.2f,%.2f,    kl,%.2f,%.2f,    l2,%.5f,                            klweight,%.2f,    l2weight,%.2f\n' % (i, train_step, tr_total_cost, ev_total_cost, tr_recon_cost, ev_recon_cost, tr_kl_cost, ev_kl_cost, l2_cost, kl_weight, l2_weight))
    else:
        print(('Epoch:%d,    step:%d    TRAIN:    total:    %.2f                    recon:    %.2f,    kl:    %.2f,                        l2:    %.5f,                kl    weight:    %.2f,    l2    weight:    %.2f' % (i, train_step, tr_total_cost, tr_recon_cost, tr_kl_cost, l2_cost, kl_weight, l2_weight)))
        csv_outstr = ('epoch,%d,    step,%d,    total,%.2f,    recon,%.2f,    kl,%.2f,                            l2,%.5f,    klweight,%.2f,    l2weight,%.2f\n' % (i, train_step, tr_total_cost, tr_recon_cost, tr_kl_cost, l2_cost, kl_weight, l2_weight))
    if self.hps.csv_log:
        csv_file = os.path.join(self.hps.lfads_save_dir, (self.hps.csv_log + '.csv'))
        with open(csv_file, 'a') as myfile:
            myfile.write(csv_outstr)
