def equivalent_shapes_gen(shape):
    """
    Generate more equivalent shapes by removing
    leading singleton dimensions from `shape`.
    e.g., shape=(1, 4, 1), yield (1, 4, 1), (4, 1)
    shape=(1, 1, 5), yield (1, 1, 5), (1, 5), (5,)
    """
    yield shape
    for i in range(len(shape) - 1):
        if shape[i] == 1:
            i += 1
            yield shape[i:]
        else:
            break

    Generate more equivalent shapes by removing
    leading singleton dimensions from `shape`.
    e.g., shape=(1, 4, 1), yield (1, 4, 1), (4, 1)
    shape=(1, 1, 5), yield (1, 1, 5), (1, 5), (5,)
    
tests/integration/test_linspace.py