How to make a custom loss function (PyTorch)

Some pytorch loss functions allow class weights to be passed in. Have you ruled that approach out? Eg nn.CrossEntropyLoss(weight=class_weights)