def _should_skip_saving_checkpoint(self, trainer: Trainer) -> bool:
        """Determine if checkpoint saving should be skipped.

        Args:
            trainer (:class:`~lightning.pytorch.Trainer`): PyTorch Lightning trainer instance.

        Returns:
            bool: ``True`` if checkpoint saving should be skipped, ``False`` otherwise.

        Note:
            The method considers the following conditions:

            - Skips if ``fast_dev_run`` is enabled
            - Skips if not in ``FITTING`` or ``VALIDATING`` state
            - Skips during sanity checking
            - For non-zero/few-shot models, skips if global step hasn't changed
        """
        is_zero_or_few_shot = trainer.lightning_module.learning_type in {LearningType.ZERO_SHOT, LearningType.FEW_SHOT}
        return (
            bool(trainer.fast_dev_run)  # disable checkpointing with fast_dev_run
            or trainer.state.fn not in {TrainerFn.FITTING, TrainerFn.VALIDATING}  # don't save anything during non-fit
            or trainer.sanity_checking  # don't save anything during sanity check
            or (self._last_global_step_saved == trainer.global_step and not is_zero_or_few_shot)
        )
Determine if checkpoint saving should be skipped.

        Args:
            trainer (:class:`~lightning.pytorch.Trainer`): PyTorch Lightning trainer instance.

        Returns:
            bool: ``True`` if checkpoint saving should be skipped, ``False`` otherwise.

        Note:
            The method considers the following conditions:

            - Skips if ``fast_dev_run`` is enabled
            - Skips if not in ``FITTING`` or ``VALIDATING`` state
            - Skips during sanity checking
            - For non-zero/few-shot models, skips if global step hasn't changed
        
src/anomalib/callbacks/checkpoint.py