import torchvision.transforms as T transform=T.Compose([T.ToTensor(), T.Lambda(lambda x: torch.flatten(x))])