Assuming you are passing a tensor to the transformation it should have at least 3 dims as [channels, height, width] and can have additional leading dimensions (e.g. the batch dimension).
If that’s the case, unsqueeze the channel dimension and remove the ToTensor transformation.
transform = transforms.Resize((256, 512))
x = torch.randn(3, 400, 600)
out = transform(x)
print(out.shape)
# > torch.Size([3, 256, 512])

x = torch.randn(503, 512)
out = transform(x)
# > ValueError: size shape must match input shape. Input is 1D, size is 2