import torch


def xyxy2xywh(box: torch.Tensor) -> torch.Tensor:
    """
        Returns the xywh format of the input bounding box tensor

        Arguments:
            box (torch.Tensor): Bounding box tensor in xyxy format

        Output:
            output (torch.Tensor): Bounding box tensor in xywh format
    """
    output = torch.zeros(box.size())
    output[..., 0] = (box[..., 2] + box[..., 0])/2
    output[..., 1] = (box[..., 3] + box[..., 1])/2
    output[..., 2] = box[..., 2] - box[..., 0]
    output[..., 3] = box[..., 3] - box[..., 1]
    output[..., 4:] = box[..., 4:]
    return output