def is_executable(self, runner):
        """Determines whether the controller is executable at current state.

        Basically, the decision is made based on the current running iteration
        (epoch) and the execution frequency (i.e., `self.every_n_iters` and
        `self.every_n_epochs`).

        If `self.master_only` is set as `True`, this function will also check
        whether the current work is the master.

        Args:
            runner: The runner to control.

        Returns:
            A boolean suggesting whether the controller should be executed.
        """
        if self.master_only and runner.rank != 0:
            return False

        if self.first_iter and runner.iter - runner.start_iter == 1:
            return True
        if runner.iter == runner.total_iters:
            return True
        if self.every_n_iters > 0 and runner.iter % self.every_n_iters == 0:
            return True
        epoch_to_iter = runner.convert_epoch_to_iter(self.every_n_epochs)
        if self.every_n_epochs > 0 and runner.iter % epoch_to_iter == 0:
            return True
        return False
Determines whether the controller is executable at current state.

        Basically, the decision is made based on the current running iteration
        (epoch) and the execution frequency (i.e., `self.every_n_iters` and
        `self.every_n_epochs`).

        If `self.master_only` is set as `True`, this function will also check
        whether the current work is the master.

        Args:
            runner: The runner to control.

        Returns:
            A boolean suggesting whether the controller should be executed.
        
runners/controllers/base_controller.py