The code looks generally alright. I don’t know, how custom_loss_fn calculates the loss without any parameters, but you might use globals for them.
You should probably also call classifier.eval() during the test case.
A minor concern might be the comparably high test loss and the high test accuracy, which don’t seem to really correlate well, so you could check the test loss calculation and accuracy again.