def _get_grid_boxes(im, rows: int, cols: int):
    """Return a list of 4-tuples for every box in a given grid of the image.
    im: Pillow image
    rows: Number of rows in the grid
    cols: Number of columns in the grid
    """
    cell_width = int(im.size[0] / cols)
    cell_height = int(im.size[1] / rows)

    grid_boxes = [
        (
            cell_x * cell_width,
            cell_y * cell_height,
            cell_x * cell_width + cell_width,
            cell_y * cell_height + cell_height
        )
        for cell_y in range(rows)
        for cell_x in range(cols)
    ]
    return grid_boxes