You could reuse the training loop and just remove the backward and optimizer.step() calls.
Also, you could wrap the validation/test loop into a with torch.no_grad() block to save some memory.
Also note that Variables are deprecated since PyTorch 0.4 and you can use tensors now.