Custom Loss in torch.lib c++

Hi everyone,
i am quite new to the torch.lib and c++ and i’m just wondering, if there any example how should i write and use my own loss function? I’m struggling the whole day through the internet and cannot find any documentation or example for that. I’m looking for DiceLoss or TverskyLoss. I have both on the python side, but now i want to use it also in my c++ code. Do you have any ideas?

Have a nice day!

You could take a look at the internal implementations e.g. for MSELoss and the corresponding functional API via mse_loss.