import torch


def unnorm(t:torch.Tensor, mean=None, std=None):
  """
  Given an image this unnormalizes the image and returns it

  Arguments
  ---------
  t : torch.Tensor
      The image to unnormalize
  mean : list,(in case of >1 channels) else float
         The mean to multiply to the image
         Defaults to: [0.485, 0.456, 0.406],
  std : list,(in case of >1 channels) else float
         The std to add to the image
         Defaults to: [0.229, 0.224, 0.225]

  Returns
  -------
  t : torch.Tensor
      The unnormalized image.
  """
  if mean is None: mean = torch.Tensor([0.485, 0.456, 0.406])
  if std is None: std = torch.Tensor([0.229, 0.224, 0.225])
  # Not sure how to change the dim while multiplying so
  # changing the channel dimension from 0 to 2
  # Performing the operations and then changing it back
  t = (t.squeeze().transpose(0, 1).transpose(1, 2) * std) + mean
  return t.transpose(2, 1).transpose(1, 0)