import torch


def cxcy_to_xy(cxcy):
    """
    Convert bounding boxes from center-size coords (c_x, c_y, w, h) to boundary coords
    (x_min, y_min, x_max, y_max).

    Args:
        cxcy: bounding boxes in center-size coords - a tensor of size (n_boxes, 4)

    Returns:
        xy: bounding boxes in boundary coords - a tensor of size (n_boxes, 4)

    """

    return torch.cat(
        [cxcy[:, :2] - (cxcy[:, 2:] / 2), cxcy[:, :2] + (cxcy[:, 2:] / 2)],
        1,  # (x_min, y_min), (x_max, y_max)
    )