Torchvision.transforms Flatten
import torchvision.transforms as T
transform=T.Compose([T.ToTensor(), T.Lambda(lambda x: torch.flatten(x))])
Wide-eyed Wolverine
import torchvision.transforms as T
transform=T.Compose([T.ToTensor(), T.Lambda(lambda x: torch.flatten(x))])