I get these 0 accuracy issues a lot by accident if I am not careful. I.e., make sure that in
op_class == labels.view(*top_class.shape)

both are flat arrays or have the same dimension if you have multiple labels. For example, if one is a [n_examples, 1] array and one a [n_examples] array, bad things can happen. Maybe just add an assert
assert op_class.size() == labels.view(*top_class.shape).size()

before that line to rule that out.