import torch


def centers_to_extents(boxes):
    """
    Convert boxes from [xc, yc, w, h] format to [x0, y0, x1, y1] format

    Input:
    - boxes: Input boxes of shape (N, 4) in [xc, yc, w, h] format

    Returns:
    - boxes: Output boxes of shape (N, 4) in [x0, y0, x1, y1] format
    """
    xc, yc = boxes[:, 0], boxes[:, 1]
    w, h = boxes[:, 2], boxes[:, 3]

    x0 = xc - w / 2
    x1 = x0 + w
    y0 = yc - h / 2
    y1 = y0 + h

    boxes_out = torch.stack([x0, y0, x1, y1], dim=1)
    return boxes_out