Could you print the entire loss function code?
Initially the error seems to be coming from how you define circ_loss as it has no grad_fn attribute (which can be seen for dice_loss and L via the grad_fn=<RsubBackward> and grad_fn=<AddBackward0> terms respectively). If you’re creating some data (or importing it from a numpy array) make sure to tell PyTorch it requires a gradient via the requries_grad_() attribute.