def check_shape(a, b):
    """Check if the shapes of given values match.

    Args:
        a (array_like, tuple): An object with shape attribute or a tuple representing shape.
        b (array_like, tuple): An object with shape attribute or a tuple representing shape.

    Raises:
        Exception: When shapes don't match.
    """
    if hasattr(a, 'shape'):
        a = a.shape
    if hasattr(b, 'shape'):
        b = b.shape
    assert a == b, f"Shapes {a} and {b} don't match"
