Padding and loading mnist dataset

I pad the Mnist dataset using transforms.Pad(2). Then when I want to iterate through the loader, I get this error:
TypeError: ‘builtin_function_or_method’ object has no attribute 'getitem
Any ideas?
Thanks

before transforms.Pad(2), you might need a ToPILImage() transform, as mnist data is returned either as a numpy array or torch tensor (i cant remember) and Pad expects PIL Image

Thanks. So should I use: transforms.Compose([transforms.ToPILImage(), transforms.Pad(2), transforms.ToTensor(), … ?
I get this error when I do it: AssertionError: pic should be Tensor or ndarray
When I switch ToPILImage() and ToTensor(), I get the previous error.