Here is a Python code snippet you can refer which resize and normalize images for training a generative model using PyTorch:
In this code we are using Resize to resize the image to the target size (e.g., 128x128), ToTensor which converts the image into a tensor with pixel values in [0, 1] and Normalize which scales pixel values to the range [-1, 1] using Normalize(mean=[0.5], std=[0.5]).