Could you explain your loss function a bit?
You are right. Even if you detach A(x) and pass it to B, you can still get gradients from A(x).
@viraat Could you check if adv_loss is used? Just define loss as
loss = adv_loss

and run your code. I think you will get a RuntimeError stating that your tensor does not require grad and does not have a grad_fn.
As classifier_loss is valid, you won’t get an error at the moment.