def task(self) -> TaskType:
        """Get the task type.

        Returns:
            TaskType: Type of anomaly task (classification/segmentation)

        Raises:
            AttributeError: If no datasets have been set up yet
        """
        if hasattr(self, "train_data"):
            return self.train_data.task
        if hasattr(self, "val_data"):
            return self.val_data.task
        if hasattr(self, "test_data"):
            return self.test_data.task
        msg = "This datamodule does not have any datasets. Did you call setup?"
        raise AttributeError(msg)
Get the task type.

        Returns:
            TaskType: Type of anomaly task (classification/segmentation)

        Raises:
            AttributeError: If no datasets have been set up yet
        
src/anomalib/data/datamodules/base/image.py