def copy_white_mask_to_template(img: np.ndarray, mask: np.ndarray, template: np.ndarray, box: list) -> np.ndarray:
    """
    Copy a masked region from an image to a template.

    Args:
        img (np.ndarray): The source image from which to copy the masked region.
        mask (np.ndarray): The binary mask defining the region to be copied.
        template (np.ndarray): The template image where the region will be pasted.
        box (list): The bounding box coordinates in the format [left, upper, right, lower].

    Returns:
        np.ndarray: The resulting image with the masked region copied to the template.
    """
    h, w, _ = template.shape

    result = template
    template_crop = template[box[1] : box[3], box[0] : box[2]]

    result[box[1] : box[3], box[0] : box[2]] = apply_mask_to_image(img, template_crop, mask)

    return result

    Copy a masked region from an image to a template.

    Args:
        img (np.ndarray): The source image from which to copy the masked region.
        mask (np.ndarray): The binary mask defining the region to be copied.
        template (np.ndarray): The template image where the region will be pasted.
        box (list): The bounding box coordinates in the format [left, upper, right, lower].

    Returns:
        np.ndarray: The resulting image with the masked region copied to the template.
    
scripts/easyphoto_utils/tryon_utils.py