def is_images_classes(images_classes: Tensor) -> None:
    """Validate image-level ground truth labels tensor.

    Args:
        images_classes: Binary tensor of shape (N,) containing image labels.

    Raises:
        ValueError: If tensor is not 1D or contains non-binary values.
        TypeError: If tensor has invalid dtype.

    Example:
        >>> classes = torch.zeros(10, dtype=torch.bool)
        >>> is_images_classes(classes)  # No error
        >>> bad_classes = torch.ones(10) * 2
        >>> is_images_classes(bad_classes)  # Raises ValueError
    """
    if images_classes.ndim != 1:
        msg = f"Expected image classes to be 1D, but got {images_classes.ndim}D."
        raise ValueError(msg)

    if images_classes.dtype == torch.bool:
        pass
    elif images_classes.dtype.is_floating_point:
        msg = (
            "Expected image classes to be an integer or boolean Tensor with "
            f"ground truth labels, but got Tensor with dtype "
            f"{images_classes.dtype}"
        )
        raise TypeError(msg)
    else:
        # assumes the type to be (signed or unsigned) integer
        # this will change with the dataclass refactor
        unique_vals = torch.unique(images_classes)
        if torch.any((unique_vals != 0) & (unique_vals != 1)):
            msg = (
                "Expected image classes to be a *binary* Tensor with ground "
                f"truth labels, but got Tensor with unique values "
                f"{sorted(unique_vals)}"
            )
            raise ValueError(msg)
Validate image-level ground truth labels tensor.

    Args:
        images_classes: Binary tensor of shape (N,) containing image labels.

    Raises:
        ValueError: If tensor is not 1D or contains non-binary values.
        TypeError: If tensor has invalid dtype.

    Example:
        >>> classes = torch.zeros(10, dtype=torch.bool)
        >>> is_images_classes(classes)  # No error
        >>> bad_classes = torch.ones(10) * 2
        >>> is_images_classes(bad_classes)  # Raises ValueError
    
src/anomalib/metrics/pimo/_validate.py