'Run the model on the data in data_dict, and save the computed values.
LFADS generates a number of outputs for each examples, and these are all
saved.  They are:
The mean and variance of the prior of g0.
The mean and variance of approximate posterior of g0.
The control inputs (if enabled)
The initial conditions, g0, for all examples.
The generator states for all time.
The factors for all time.
The output distribution parameters (e.g. rates) for all time.
Args:
datasets: a dictionary of named data_dictionaries, see top of lfads.py
output_fname: a file name stem for the output files.'

def write_model_runs(self, datasets, output_fname=None):

    hps = self.hps
    kind = hps.kind
    for (data_name, data_dict) in datasets.items():
        data_tuple = [('train', data_dict['train_data'], data_dict['train_ext_input']), ('valid', data_dict['valid_data'], data_dict['valid_ext_input'])]
        for (data_kind, data_extxd, ext_input_extxi) in data_tuple:
            if (not output_fname):
                fname = ((((('model_runs_' + data_name) + '_') + data_kind) + '_') + kind)
            else:
                fname = (((((output_fname + data_name) + '_') + data_kind) + '_') + kind)
            print(('Writing    data    for    %s    data    and    kind    %s.' % (data_name, data_kind)))
            model_runs = self.eval_model_runs_avg_epoch(data_name, data_extxd, ext_input_extxi)
            full_fname = os.path.join(hps.lfads_save_dir, fname)
            write_data(full_fname, model_runs, compression='gzip')
            print('Done.')
