def get_grid_size(grid):
    """Get sizes of grid."""
    sizes = []
    sub_grid = grid
    while isinstance(sub_grid, list):
        sizes.append(len(sub_grid))
        sub_grid = sub_grid[0]
    return sizes[::-1]