and i am using the standard method provided by torchvision to save images here :
torchvision.utils.save_image(target_rgb, filename_target)
torchvision.utils.save_image(y_threshed, filename_output)
torchvision.utils.save_image(image, filename_input)
and using PIL :
def saving_func(batch_tensor, path):
for i in range(batch_tensor.shape[0]):	
b = np.asarray(batch_tensor.cpu().numpy())
a = b[i,:,:,:]
a =np.swapaxes(a,0,2)
a =np.swapaxes(a,1,0)
a = Image.fromarray(a.astype(‘uint8’))
a.save(path + str("_") + str(i) + str(".jpg"))