Could you check the shape of y_train and predicted_labels and make sure that no broadcasting takes place?
Also, check the type() of the comparison and cast the result to long() or float() if necessary to avoid an overflow. (If I recall correctly, the result might be an uint8 in older PyTorch versions).
PS: Don’t use the .data attribute, as it might have unwanted side effects.