I’m not sure I understand the use case completely, but you can manually calculate the loss using al (differentiable) PyTorch operations and don’t necessarily need to stick to the pre-defined loss functions defined in the nn namespace.