def __init__(self, folder,
                 name,
                 *,
                 tracked_obj,
                 tracked_attrs=None,
                 keep_history=1,
                 keep_best=1,
                 mkdir=True):
        """
        Args:
            folder: checkpoint folder path
            name: prefix of the checkpoint
            tracked_obj: arbitrary object whose certain attributes will be tracked.
                typically Learner or Agent class
            tracked_attrs: tracked attribute names of the object, can include
                attrs that point to torch.nn.Module
                set to None if you will restore from existing checkpoint
            keep_history: how many checkpoints to keep, must >= 1
            keep_best: how many best models to keep, sorted by score, must >= 0
            mkdir: True to create intermediate dirs if the path doesn't exist
        """
        self.folder = U.f_expand(folder)
        if mkdir:
            U.f_mkdir(folder)
        self.name = name
        self.tracked_obj = tracked_obj

        if U.f_exists(self.metadata_path()):
            self._load_metadata()
        else:
            # blank-slate checkpoint
            metadata = BeneDict()
            metadata.version = CHEKCPOINT_VERSION
            metadata.save_counter = 0
            metadata.history_ckpt_files = []
            metadata.ckpt = {}
            self._check_tracked_attrs(tracked_attrs)
            metadata.tracked_attrs = tracked_attrs
            assert keep_history >= 1
            metadata.keep_history = keep_history
            assert keep_best >= 0
            metadata.keep_best = keep_best
            metadata.best_ckpt_files = []
            metadata.best_scores = []
            self.metadata = metadata

        Args:
            folder: checkpoint folder path
            name: prefix of the checkpoint
            tracked_obj: arbitrary object whose certain attributes will be tracked.
                typically Learner or Agent class
            tracked_attrs: tracked attribute names of the object, can include
                attrs that point to torch.nn.Module
                set to None if you will restore from existing checkpoint
            keep_history: how many checkpoints to keep, must >= 1
            keep_best: how many best models to keep, sorted by score, must >= 0
            mkdir: True to create intermediate dirs if the path doesn't exist
        
surreal/utils/checkpoint.py