Using dice loss in cnn_learner

I have searched and searched the forums, but I cannot seem to make this work.

I have a binary classification problem where one class is about 8% of the samples. I had the idea that the dice loss function would be good for this. However, I cannot seem to figure out what I put in cnn_learner to make this work:

learn = cnn_learner(data, 
                    models.resnet152,
                    loss_func=?)

I have it in the metrics currently and it works great there, so I’m baffled as to what I might be doing wrong in using it as a loss function. I have tried hunting down various implementations of dice loss and tried using them, but they all gave one error or another. Does anyone know of an implementation that will work with the current version of fast.ai? Also, I am open to suggestions for any other loss functions that might be worth trying out.