def get_array_dimensions(data):
    """
    Given an array type data item, check that it is an array and
    return the dimensions as a tuple.
    Ex: get_array_dimensions([[1, 2, 3], [4, 5, 6]]) returns (2, 3)
    """
    depths_and_dimensions = get_depths_and_dimensions(data, 0)
    # re-form as a dictionary with `depth` as key, and all of the dimensions found at that depth.
    grouped_by_depth = {
        depth: tuple(dimension for depth, dimension in group)
        for depth, group in groupby(depths_and_dimensions, itemgetter(0))
    }

    # validate that there is only one dimension for any given depth.
    invalid_depths_dimensions = tuple(
        (depth, dimensions)
        for depth, dimensions in grouped_by_depth.items()
        if len(set(dimensions)) != 1
    )
    if invalid_depths_dimensions:
        raise ValidationError(
            '\n'.join(
                [
                    "Depth {0} of array data has more than one dimensions: {1}".
                    format(depth, dimensions)
                    for depth, dimensions in invalid_depths_dimensions
                ]
            )
        )

    dimensions = tuple(
        toolz.first(set(dimensions))
        for depth, dimensions in sorted(grouped_by_depth.items())
    )

    return dimensions
Given an array type data item, check that it is an array and
    return the dimensions as a tuple.
    Ex: get_array_dimensions([[1, 2, 3], [4, 5, 6]]) returns (2, 3)