In your code sample, you run hidden = detach(hidden) just after creating hidden from ne Variables.
detach can only remove the existing computation graph of hidden and at the point where you call hidden there is no computation graph attached to hidden.