If you are permuting along the batch dimension each sample will have pixel information of some other samples from the batch. Is that your intention or do you rather want to permute the pixels in each sample in a defined manner?
In the latter case, you can just use this code sample:
dataset = datasets.MNIST(root='./data',
                         download=False,
                         transform=transforms.ToTensor())

shuffle_idx = torch.randperm(28*28)
data = [dataset[i][0] for i in range(10)]
target = torch.stack([dataset[i][1] for i in range(10)], dim=0)

# Show first sample
plt.figure()
plt.imshow(data[0][0])

# Permute the pixels
data = torch.stack([x.view(-1)[shuffle_idx].view(1, 28, 28) for x in data], dim=0)

# Show after permutation
plt.figure()
plt.imshow(data[0][0])