Thanks, this resolved the problem.
But now i get another error
On
accuracy_valid = 100. * predictions.eq(dataset_valid.dataset.targets).sum().float() / len(dataset_valid)

I get
RuntimeError: The size of tensor a (5000) must match the size of tensor b (10000) at non-singleton dimension 0

To check i did
print ("\nTrain data are %d, with shape %s" % (len(dataset_train), dataset_train.data.shape))

That prints
Validation data are 5000, with shape torch.Size([10000, 28, 28])

I am very confused, I would be grateful if you could help me.