def _setup(self, _stage: str | None = None) -> None:
        """Set up the datasets and perform dynamic subset splitting.

        This method may be overridden in subclass for custom splitting behaviour.

        Note:
            The stage argument is not used here. This is because, for a given
            instance of an AnomalibDataModule subclass, all three subsets are
            created at the first call of setup(). This is to accommodate the
            subset splitting behaviour of anomaly tasks, where the validation set
            is usually extracted from the test set, and the test set must
            therefore be created as early as the `fit` stage.
        """
        # MVTec LOCO provides a training set that contains only normal images.
        self.train_data = MVTecLOCODataset(
            split=Split.TRAIN,
            root=self.root,
            category=self.category,
        )

        # MVTec LOCO provides a validation set that contains only normal images.
        self.val_data = MVTecLOCODataset(
            split=Split.VAL,
            root=self.root,
            category=self.category,
        )

        # MVTec LOCO provides a test set that contains both normal and anomalous images.
        # Anomalous images are further divided into structural and logical anomalies.
        self.test_data = MVTecLOCODataset(
            split=Split.TEST,
            root=self.root,
            category=self.category,
        )
Set up the datasets and perform dynamic subset splitting.

        This method may be overridden in subclass for custom splitting behaviour.

        Note:
            The stage argument is not used here. This is because, for a given
            instance of an AnomalibDataModule subclass, all three subsets are
            created at the first call of setup(). This is to accommodate the
            subset splitting behaviour of anomaly tasks, where the validation set
            is usually extracted from the test set, and the test set must
            therefore be created as early as the `fit` stage.
        
src/anomalib/data/datamodules/image/mvtec_loco.py