def _create_val_split(self) -> None:
        """Create validation split based on configured mode.

        This handles sampling from train/test sets and optionally creating
        synthetic anomalies.
        """
        if self.val_split_mode == ValSplitMode.FROM_DIR:
            # If the validation split mode is FROM_DIR, we don't need to create a validation set
            return
        if self.val_split_mode == ValSplitMode.FROM_TRAIN:
            # randomly sample from train set
            self.train_data, self.val_data = random_split(
                self.train_data,
                self.val_split_ratio,
                label_aware=True,
                seed=self.seed,
            )
        elif self.val_split_mode == ValSplitMode.FROM_TEST:
            # randomly sample from test set
            self.test_data, self.val_data = random_split(
                self.test_data,
                self.val_split_ratio,
                label_aware=True,
                seed=self.seed,
            )
        elif self.val_split_mode == ValSplitMode.SAME_AS_TEST:
            # equal to test set
            self.val_data = copy.deepcopy(self.test_data)
        elif self.val_split_mode == ValSplitMode.SYNTHETIC:
            # create synthetic anomalies from training samples
            self.train_data, normal_val_data = random_split(
                self.train_data,
                self.val_split_ratio,
                seed=self.seed,
            )
            self.val_data = SyntheticAnomalyDataset.from_dataset(normal_val_data)
        elif self.val_split_mode != ValSplitMode.NONE:
            msg = f"Unknown validation split mode: {self.val_split_mode}"
            raise ValueError(msg)
Create validation split based on configured mode.

        This handles sampling from train/test sets and optionally creating
        synthetic anomalies.
        
src/anomalib/data/datamodules/base/image.py