I can’t see any line of code, which would detach a tensor from the graph.
If you are concerned about detaching, you could check the .grad attribute of all parameters after the backward call. If they contain valid values, your graph wasn’t detached, and I would recommend to try to overfit a small data sample as a quick test.