You said you are computing auc  and backpropagating from there. As it is c++ you are pasting the gradient.
You can create a python wrapper which takes as input that layer and returns the auc as a tensor relying in that c++ implementation. This way you will be able to call auc.backward