import torch


def rescale_img(imgs):
    """
    Rescale the values of an images from [-1,1] to [0, 255] and permute the channels of the images from [N, C, H, W] to
    [N, H, W, C].
    Args:
        imgs:   Image to rescale.

    Returns: Rescaled images.
    """
    return (imgs.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8)