This error is raised, if you are trying to compare more than a single value without calling all() or any() on the result.
This comparison:
labels[i] == predicted[i]

is apparently creating multiple result values so you could check the shape of labels[i] and predicted[i] and make sure to apply the right behavior.