How to update RPN in Faster RCNN?

I want to update the loss function of the RPN in FasterRCNN. See these lines here, which refers to the loss function here.

I’m trying to update this compute_loss function in my code like so:

rpn.RegionProposalNetwork.compute_loss = custom_loss

However, this is not changing anything. Any idea how to update the RPN’s loss function?