import math


def bound_box(idx, w, length, size, overlap_pixel):
    """
    Function that return the bounding box of a word given its index
    Args:
        ind: int, ind < number of words

    Returns:
        Bounding box(int[]): [h_low, h_high, w_low, w_high]
    """
    assert idx < length, "Index Out of Bound"
    num_bag_w = int((w - overlap_pixel) / (size - overlap_pixel))
    box_h = int(math.floor(idx / num_bag_w) * (size - overlap_pixel))
    box_w = int(idx % (num_bag_w) * (size - overlap_pixel))

    return [box_h, box_h + size, box_w, box_w + size]