def decode(self, box: torch.Tensor, cls: torch.Tensor, stage: int):
        """RTMDet postprocess function.

        Args:
            box (torch.Tensor): output boxes.
            cls (torch.Tensor): output cls.
            stage (int): RTMDet output stage.

        Returns:
            torch.Tensor: The decode boxes.
                Format is [x1, y1, x2, y2, class, confidence]
        """
        cls = F.sigmoid(cls)
        conf = torch.max(cls, dim=3, keepdim=True)[0]
        cls = torch.argmax(cls, dim=3, keepdim=True).to(torch.float32)

        box = torch.cat([box, cls, conf], dim=-1)

        step = self.input_shape // self.stage[stage]

        block_step = torch.linspace(
            0, self.stage[stage] - 1, steps=self.stage[stage],
            device='cuda') * step
        block_x = torch.broadcast_to(block_step,
                                     [self.stage[stage], self.stage[stage]])
        block_y = torch.transpose(block_x, 1, 0)
        block_x = torch.unsqueeze(block_x, 0)
        block_y = torch.unsqueeze(block_y, 0)
        block = torch.stack([block_x, block_y], -1)

        box[..., :2] = block - box[..., :2]
        box[..., 2:4] = block + box[..., 2:4]
        box = box.reshape(1, -1, 6)
        return box
RTMDet postprocess function.

        Args:
            box (torch.Tensor): output boxes.
            cls (torch.Tensor): output cls.
            stage (int): RTMDet output stage.

        Returns:
            torch.Tensor: The decode boxes.
                Format is [x1, y1, x2, y2, class, confidence]
        
mmpose/projects/rtmpose/examples/RTMPose-Deploy/Windows/TensorRT/python/convert_rtmdet.py