def is_same_shape(*args) -> None:
    """Validate that all arguments have the same shape.

    Works for both tensors and ndarrays.

    Args:
        *args: Variable number of tensors or ndarrays to compare shapes.

    Raises:
        ValueError: If arguments have different shapes.

    Example:
        >>> import torch
        >>> t1 = torch.zeros(2, 3)
        >>> t2 = torch.ones(2, 3)
        >>> is_same_shape(t1, t2)  # No error
        >>> t3 = torch.zeros(3, 2)
        >>> is_same_shape(t1, t3)  # Raises ValueError
        ValueError: Expected arguments to have the same shape, but got [(2, 3), (3, 2)]
    """
    assert len(args) > 0
    shapes = sorted({tuple(arg.shape) for arg in args})
    if len(shapes) > 1:
        msg = f"Expected arguments to have the same shape, but got {shapes}"
        raise ValueError(msg)
Validate that all arguments have the same shape.

    Works for both tensors and ndarrays.

    Args:
        *args: Variable number of tensors or ndarrays to compare shapes.

    Raises:
        ValueError: If arguments have different shapes.

    Example:
        >>> import torch
        >>> t1 = torch.zeros(2, 3)
        >>> t2 = torch.ones(2, 3)
        >>> is_same_shape(t1, t2)  # No error
        >>> t3 = torch.zeros(3, 2)
        >>> is_same_shape(t1, t3)  # Raises ValueError
        ValueError: Expected arguments to have the same shape, but got [(2, 3), (3, 2)]
    
src/anomalib/metrics/pimo/_validate.py