import torch


def torch_image_to_numpy(image_torch, inplace=False):
    """Convert PyTorch tensor to Numpy array.
    :param image_torch: PyTorch float CHW Tensor in range [0..1].
    :param inplace: modify the tensor in-place.
    :returns: Numpy uint8 HWC array in range [0..255]."""
    if not inplace:
        image_torch = image_torch.clone()
    return image_torch.mul_(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to('cpu', torch.uint8).numpy()