I guess prediction == labels.data might return a bool instead of a tensor.
Could you remove the .data usage and rerun the code, please?
Generally the usage of .data is not recommended, as it might yield unwanted side effects.
Also, Variables are deprecated since PyTorch 0.4, so you can use tensors in newer versions.
Let me know, if that helps solving the issue.