import torch


def xyxys2xyxysc(dets):
    """Convert detection format List[(x1,y1,x2,y2,score)*] to (x1,y1,x2,y2,score,cls)
    Args:
        dets(List[Tensor[N, 5]]: list of detections by in class order from one frame
    Returns:
        xyxysc(Tensor[N, 6]): detections of one frame
    """
    xyxysc = []
    count = len(dets)
    if count <= 0:
        return torch.Tensor(0, 6)
    device = None
    for c, detsC in enumerate(dets):
        if detsC is not None:
            device = detsC.device
            C = torch.Tensor([c], device=detsC.device).expand(len(detsC), 1)
            detsC = torch.cat((detsC, C), dim=1)
            xyxysc.append(detsC)
    xyxysc = torch.cat(xyxysc)
    return xyxysc