def expand_roi(box: List[int], ratio: float, max_box: List[int], eps: int = 0) -> List[int]:
    """
    Expand a region of interest (ROI) box by a given ratio while ensuring it doesn't exceed the specified maximum box.

    Args:
        box (List[int]): The original ROI box coordinates [left, upper, right, lower].
        ratio (float): The expansion ratio applied to the ROI box.
        max_box (List[int]): The maximum bounding box within which the ROI must be contained [left, upper, right, lower].
        eps (int, optional): An epsilon value to add to the width and height during expansion (default is 0).

    Returns:
        List[int]: The expanded ROI box coordinates [left, upper, right, lower].
    """
    centerx = (box[0] + box[2]) / 2
    centery = (box[1] + box[3]) / 2
    w = box[2] - box[0]
    h = box[3] - box[1]

    nw = w * ratio + eps
    nh = h * ratio + eps

    b0 = int(max(centerx - nw / 2, max_box[0]))
    b1 = int(max(centery - nh / 2, max_box[1]))
    b2 = int(min(centerx + nw / 2, max_box[2]))
    b3 = int(min(centery + nh / 2, max_box[3]))

    return [b0, b1, b2, b3]

    Expand a region of interest (ROI) box by a given ratio while ensuring it doesn't exceed the specified maximum box.

    Args:
        box (List[int]): The original ROI box coordinates [left, upper, right, lower].
        ratio (float): The expansion ratio applied to the ROI box.
        max_box (List[int]): The maximum bounding box within which the ROI must be contained [left, upper, right, lower].
        eps (int, optional): An epsilon value to add to the width and height during expansion (default is 0).

    Returns:
        List[int]: The expanded ROI box coordinates [left, upper, right, lower].
    
scripts/easyphoto_utils/tryon_utils.py