def load(self,
             filepath,
             running_metadata=True,
             learning_rate=True,
             optimizer=True,
             running_stats=False,
             map_location='cpu'):
        """Loads previous running status.

        Args:
            filepath: File path to load the checkpoint.
            running_metadata: Whether to load the running metadata, such as
                batch size, current iteration, etc. (default: True)
            learning_rate: Whether to load the learning rate. (default: True)
            optimizer: Whether to load the optimizer. (default: True)
            running_stats: Whether to load the running stats. (default: False)
            map_location: Map location used for model loading. (default: `cpu`)
        """
        self.logger.info(f'Resuming from checkpoint `{filepath}` ...')
        if not os.path.isfile(filepath):
            raise IOError(f'Checkpoint `{filepath}` does not exist!')
        map_location = map_location.lower()
        assert map_location in ['cpu', 'gpu']
        if map_location == 'gpu':
            device = torch.cuda.current_device()
            map_location = lambda storage, location: storage.cuda(device)
        checkpoint = torch.load(filepath, map_location=map_location)
        # Load models.
        if 'models' not in checkpoint:
            checkpoint = {'models': checkpoint}
        for model_name, model in self.models.items():
            if model_name not in checkpoint['models']:
                self.logger.warning(f'Model `{model_name}` is not included in '
                                    f'the checkpoint, and hence will NOT be '
                                    f'loaded!')
                continue
            state_dict = _strip_state_dict_prefix(
                checkpoint['models'][model_name])
            model.load_state_dict(state_dict)
            self.logger.info(f'  Successfully loaded model `{model_name}`.')
        # Load running metedata.
        if running_metadata:
            if 'running_metadata' not in checkpoint:
                self.logger.warning(f'Running metadata is not included in the '
                                    f'checkpoint, and hence will NOT be '
                                    f'loaded!')
            else:
                self._iter = checkpoint['running_metadata']['iter']
                self._start_iter = self._iter
                self.seen_img = checkpoint['running_metadata']['seen_img']
        # Load optimizers.
        if optimizer:
            if 'optimizers' not in checkpoint:
                self.logger.warning(f'Optimizers are not included in the '
                                    f'checkpoint, and hence will NOT be '
                                    f'loaded!')
            else:
                for opt_name, opt in self.optimizers.items():
                    if opt_name not in checkpoint['optimizers']:
                        self.logger.warning(f'Optimizer `{opt_name}` is not '
                                            f'included in the checkpoint, and '
                                            f'hence will NOT be loaded!')
                        continue
                    opt.load_state_dict(checkpoint['optimizers'][opt_name])
                    self.logger.info(f'  Successfully loaded optimizer '
                                     f'`{opt_name}`.')
        # Load learning rates.
        if learning_rate:
            if 'learning_rates' not in checkpoint:
                self.logger.warning(f'Learning rates are not included in the '
                                    f'checkpoint, and hence will NOT be '
                                    f'loaded!')
            else:
                for lr_name, lr in self.lr_schedulers.items():
                    if lr_name not in checkpoint['learning_rates']:
                        self.logger.warning(f'Learning rate `{lr_name}` is not '
                                            f'included in the checkpoint, and '
                                            f'hence will NOT be loaded!')
                        continue
                    lr.load_state_dict(checkpoint['learning_rates'][lr_name])
                    self.logger.info(f'  Successfully loaded learning rate '
                                     f'`{lr_name}`.')
        # Load running stats.
        if running_stats:
            if 'running_stats' not in checkpoint:
                self.logger.warning(f'Running stats is not included in the '
                                    f'checkpoint, and hence will NOT be '
                                    f'loaded!')
            else:
                self.running_stats = deepcopy(checkpoint['running_stats'])
                self.logger.info(f'  Successfully loaded running stats.')
        # Log message.
        tailing_message = ''
        if running_metadata and 'running_metadata' in checkpoint:
            tailing_message = f' (iteration {self.iter})'
        self.logger.info(f'Successfully resumed from checkpoint `{filepath}`.'
                         f'{tailing_message}')
Loads previous running status.

        Args:
            filepath: File path to load the checkpoint.
            running_metadata: Whether to load the running metadata, such as
                batch size, current iteration, etc. (default: True)
            learning_rate: Whether to load the learning rate. (default: True)
            optimizer: Whether to load the optimizer. (default: True)
            running_stats: Whether to load the running stats. (default: False)
            map_location: Map location used for model loading. (default: `cpu`)
        
runners/base_runner.py