from torchvision.utils import save_image ... save_image(im, f\'im_name.png\')
In my case (standard mnist), using code from here, im is
im