Isn’t this the max margin loss 17?
That said, the beauty of PyTorch is that you aren’t forced to designate something a loss function, to define your own, just write out the computation and take the backward.
Best regards
Thomas