Are you sure you didn't find what you wanted here? Coz I'm amazed at the loss functions covered by PyTorch.
Please search the forum once before asking, as this question was discussed multiple times in the past. This thread will be really helpful.
If interested, do check out how they've coded the existing ones. It's actually quite simple. You can check it out here