def METHOD_NAME(self, evaluator: Evaluator):
    assert self.interval_steps >= self.training_steps or self.interval_steps < 0
    self._remaining_times = self.total_times
    def optimizer_task():
        self._current_step += 1
        if self._current_step == self.training_steps:
            masks = self.generate_masks()
            self.update_masks(masks)
            if isinstance(self._remaining_times, int):
                self._remaining_times -= 1
            debug_msg = f'{self.__class__.__name__} generate masks, remaining times {self._remaining_times}'
            _logger.debug(debug_msg)
        if self._current_step == self.interval_steps and \
            (self._remaining_times == 'unlimited' or self._remaining_times > 0):  # type: ignore
            self._current_step = 0
            for _, hooks in self.hooks.items():
                for _, hook in hooks.items():
                    hook.buffer.clear()
    evaluator.patch_optimizer_step(before_step_tasks=[], after_step_tasks=[optimizer_task])