def _setup(self, _stage: str | None = None) -> None:
        """Set up video datasets and perform validation split.

        This method initializes the train and test datasets and creates the
        validation split if specified. It ensures that both train and test
        datasets are properly defined and configured.

        Args:
            _stage: Current stage of training. Defaults to ``None``.

        Raises:
            ValueError: If ``train_data`` or ``test_data`` is ``None``.
            ValueError: If ``val_split_mode`` is set to ``SYNTHETIC``.
        """
        if self.train_data is None:
            msg = "self.train_data cannot be None."
            raise ValueError(msg)

        if self.test_data is None:
            msg = "self.test_data cannot be None."
            raise ValueError(msg)

        self.train_data.setup()
        self.test_data.setup()

        if self.val_split_mode == ValSplitMode.SYNTHETIC:
            msg = f"Val split mode {self.test_split_mode} not supported for video datasets."
            raise ValueError(msg)

        self._create_val_split()
Set up video datasets and perform validation split.

        This method initializes the train and test datasets and creates the
        validation split if specified. It ensures that both train and test
        datasets are properly defined and configured.

        Args:
            _stage: Current stage of training. Defaults to ``None``.

        Raises:
            ValueError: If ``train_data`` or ``test_data`` is ``None``.
            ValueError: If ``val_split_mode`` is set to ``SYNTHETIC``.
        
src/anomalib/data/datamodules/base/video.py