The calculation looks alright.
Your model might just overfit to class0, thus predicting every sample as this class.
Check the prediction distribution using
print(pred.unique(return_counts=True))

to see, whether your model predicts other classes.