def get_depths_and_dimensions(data, depth):
    """
    Yields 2-length tuples of depth and dimension of each element at that depth
    """
    if not isinstance(data, (list, tuple)):
        # Not checking for Iterable instance, because even Dictionaries and strings
        # are considered as iterables, but that's not what we want the condition to be.
        return ()

    yield depth, len(data)

    for item in data:
        # iterating over all 1 dimension less sub-data items
        yield from get_depths_and_dimensions(item, depth + 1)
Yields 2-length tuples of depth and dimension of each element at that depth