I think essentially my custom loss function is more like a ranking-purpose function than a classification one. Saying this I mean: if the y_pred looks up pred_samples which can satisfy less mseloss when being compared to true_samples, then y_pred is assumed to stand out in the candidate list among all possible y classes.
Also, I read some other resources, do you think if these materials can lead me in the right direction?

https://bouthilx.wordpress.com/2013/04/21/a-soft-argmax/ 1
https://github.com/MWPainter/cvpr2019/blob/master/stitched/soft_argmax.py#L82 1

Thanks a lot for your time and reply.