'Save history'

def save_history(self, epoch, model):

    if (len(self.checkpoint_files) > self.history):
        fn = self.checkpoint_files.popleft()
        try:
            os.remove(fn)
            logger.info(('removed    old    checkpoint    %s' % fn))
        except OSError:
            logger.warn(('Could    not    delete    old    checkpoint    file    %s' % fn))
    path_split = os.path.splitext(self.save_path)
    save_path = ('%s_%d%s' % (path_split[0], epoch, path_split[1]))
    self.checkpoint_files.append(save_path)
    save_obj(model.serialize(keep_states=True), save_path)
    try:
        if os.path.islink(self.save_path):
            os.remove(self.save_path)
        os.symlink(os.path.split(save_path)[(-1)], self.save_path)
    except OSError:
        logger.warn(('Could    not    create    latest    model    symlink    %s    ->    %s' % (self.save_path, save_path)))
