def has_at_least_one_anomalous_image(masks: torch.Tensor) -> None:
    """Validate presence of at least one anomalous image.

    Args:
        masks: Binary tensor of shape (N, H, W) containing ground truth masks.

    Raises:
        ValueError: If no anomalous images are found.

    Example:
        >>> masks = torch.ones(10, 32, 32, dtype=torch.bool)  # All anomalous
        >>> has_at_least_one_anomalous_image(masks)  # No error
        >>> normal_masks = torch.zeros(10, 32, 32, dtype=torch.bool)
        >>> has_at_least_one_anomalous_image(normal_masks)  # Raises ValueError
    """
    is_masks(masks)
    image_classes = images_classes_from_masks(masks)
    if (image_classes == 1).sum() == 0:
        msg = "Expected at least one ANOMALOUS image, but found none."
        raise ValueError(msg)
Validate presence of at least one anomalous image.

    Args:
        masks: Binary tensor of shape (N, H, W) containing ground truth masks.

    Raises:
        ValueError: If no anomalous images are found.

    Example:
        >>> masks = torch.ones(10, 32, 32, dtype=torch.bool)  # All anomalous
        >>> has_at_least_one_anomalous_image(masks)  # No error
        >>> normal_masks = torch.zeros(10, 32, 32, dtype=torch.bool)
        >>> has_at_least_one_anomalous_image(normal_masks)  # Raises ValueError
    
src/anomalib/metrics/pimo/_validate.py