def setup(self, trainer: Trainer, pl_module: AnomalibModule, stage: str | None = None) -> None:
        """Call when inference begins.

        This method is called by PyTorch Lightning when inference begins. It loads the model
        weights from the specified path into the module's state dict.

        Args:
            trainer (Trainer): PyTorch Lightning trainer instance.
            pl_module (AnomalibModule): The module to load weights into.
            stage (str | None, optional): Current stage of execution. Defaults to ``None``.

        Note:
            The weights are loaded using ``torch.load`` with automatic device mapping based on
            the module's device. The state dict is expected to have a ``"state_dict"`` key
            containing the model weights.
        """
        del trainer, stage  # These variables are not used.

        logger.info("Loading the model from %s", self.weights_path)
        pl_module.load_state_dict(
            torch.load(self.weights_path, map_location=pl_module.device, weights_only=True)["state_dict"],
        )
Call when inference begins.

        This method is called by PyTorch Lightning when inference begins. It loads the model
        weights from the specified path into the module's state dict.

        Args:
            trainer (Trainer): PyTorch Lightning trainer instance.
            pl_module (AnomalibModule): The module to load weights into.
            stage (str | None, optional): Current stage of execution. Defaults to ``None``.

        Note:
            The weights are loaded using ``torch.load`` with automatic device mapping based on
            the module's device. The state dict is expected to have a ``"state_dict"`` key
            containing the model weights.
        
src/anomalib/callbacks/model_loader.py