def split_by_label(
    dataset: "data.AnomalibDataset",
) -> tuple["data.AnomalibDataset", "data.AnomalibDataset"]:
    """Split dataset into normal and anomalous subsets.

    Args:
        dataset: Dataset to split by label

    Returns:
        Tuple containing:
            - Dataset with only normal samples (label 0)
            - Dataset with only anomalous samples (label 1)

    Example:
        >>> normal, anomalous = split_by_label(dataset)
        >>> len(normal) + len(anomalous) == len(dataset)
        True
    """
    samples = dataset.samples
    normal_indices = samples[samples.label_index == 0].index
    anomalous_indices = samples[samples.label_index == 1].index

    normal_subset = dataset.subsample(list(normal_indices))
    anomalous_subset = dataset.subsample(list(anomalous_indices))
    return normal_subset, anomalous_subset
Split dataset into normal and anomalous subsets.

    Args:
        dataset: Dataset to split by label

    Returns:
        Tuple containing:
            - Dataset with only normal samples (label 0)
            - Dataset with only anomalous samples (label 1)

    Example:
        >>> normal, anomalous = split_by_label(dataset)
        >>> len(normal) + len(anomalous) == len(dataset)
        True
    
src/anomalib/data/utils/split.py