def save(self, score=None,
             global_steps=None,
             reload_metadata=False,
             **ckpt_info):
        """
        save to `<name>.<global_steps>.ckpt` file

        Args:
            score: float scalar to be compared, for `keep_best`
            global_steps: if None, will use internal save counter
            reload_metadata: True to overwrite self.metadata with disk version
            ckpt_info: additional metadata info for this ckpt
        """
        if reload_metadata:
            self._load_metadata()
        meta = self.metadata
        meta.save_counter += 1
        if global_steps is None:
            global_steps = meta.save_counter
        # save the last step
        suffix = global_steps
        self._save_ckpt(suffix)

        meta.global_steps = global_steps
        # history_ckpt_files count from the newest to the oldest
        meta.history_ckpt_files = [self.ckpt_name(suffix)] + meta.history_ckpt_files
        # delete older history ckpt files.
        ckpt_to_remove = meta.history_ckpt_files[meta.keep_history:]
        for ckpt_name in ckpt_to_remove:
            U.f_remove(self._get_path(ckpt_name))
        del meta.history_ckpt_files[meta.keep_history:]
        # add a ckpt entry to metadata
        ckpt_metadata_entry = {
            'score': score,
            'global_steps': global_steps,
            'save_counter': meta.save_counter,
            'time': time.time(),
            'datetime': str(datetime.datetime.now()),
        }
        ckpt_metadata_entry.update(ckpt_info)
        meta.ckpt[self.ckpt_name(suffix)] = ckpt_metadata_entry
        # save the best-performing weights
        if meta.keep_best > 0:
            assert score is not None, \
                'score cannot be None if keep_best is enabled'
            score_queue = _ScoreQueue(meta.keep_best)
            to_deletes = score_queue.set_queue(
                meta.best_scores, meta.best_ckpt_files)
            best_ckpt_name = self.ckpt_name('best-{}'.format(suffix))
            evict = score_queue.add(score, best_ckpt_name)
            if evict is None or evict[1] != best_ckpt_name:
                # the latest ckpt is not evicted from best queue
                self._copy_last_to_best(suffix)
                meta.ckpt[best_ckpt_name] = ckpt_metadata_entry
            if evict:
                to_deletes.append(evict)
            for _, ckpt_to_delete in to_deletes:
                ckpt_path_to_delete = self._get_path(ckpt_to_delete)
                if U.f_exists(ckpt_path_to_delete):
                    U.f_remove(ckpt_path_to_delete)
                if ckpt_to_delete in meta.ckpt:
                    del meta.ckpt[ckpt_to_delete]
            # print(score_queue.get_scores_filepaths(), best_ckpt_name)
            meta.best_scores, meta.best_ckpt_files = \
                score_queue.get_scores_filepaths()

        self._save_metadata()

        save to `<name>.<global_steps>.ckpt` file

        Args:
            score: float scalar to be compared, for `keep_best`
            global_steps: if None, will use internal save counter
            reload_metadata: True to overwrite self.metadata with disk version
            ckpt_info: additional metadata info for this ckpt
        
surreal/utils/checkpoint.py