import torch


def invert_convert_to_box_list(x: torch.Tensor, original_width: int, original_height: int) -> torch.Tensor:
    """ takes input of shape: (*, width x height, ch)
        and return shape: (*, ch, width, height)
    """
    assert x.shape[-2] == original_width * original_height
    return x.transpose(dim0=-1, dim1=-2).view(list(x.shape[:-2]) + [x.shape[-1], original_width, original_height])