import torch


def box_wh_to_xy(x):
    """
    Converts co-ordinates from (x, y, w, h) to 
    (x1, y1, x2, y2) format 
    """
    x, y, w, h = x.unbind(-1)
    
    x1 = x - 0.5 * w
    y1 = y - 0.5 * h
    x2 = x + 0.5 * w
    y2 = y + 0.5 * h

    return torch.stack([x1, y1, x2, y2], dim=-1)