def is_masks(masks: Tensor) -> None:
    """Validate ground truth mask tensor.

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

    Raises:
        ValueError: If tensor does not have 3 dimensions or contains non-binary
            values.
        TypeError: If tensor has invalid dtype.

    Example:
        >>> masks = torch.zeros(10, 32, 32, dtype=torch.bool)
        >>> is_masks(masks)  # No error
        >>> bad_masks = torch.ones(10, 32, 32) * 2
        >>> is_masks(bad_masks)  # Raises ValueError
    """
    if masks.ndim != 3:
        msg = f"Expected masks have 3 dimensions (N, H, W), but got {masks.ndim} dimensions"
        raise ValueError(msg)

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

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

    Raises:
        ValueError: If tensor does not have 3 dimensions or contains non-binary
            values.
        TypeError: If tensor has invalid dtype.

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