Hi,
Indices of incorrect examples are wrong.
idxs_mask = (pred == target).view(-1)

Replace this line with the following code.
idxs_mask = ((pred == target) == False).nonzero()

Thanks
regards
Pranavan