Here x does not contain the leaf Variable for which gradients are computed, but the result of the operation .to(device).

I am a bit of newbie. Could you elaborate on this a bit more. Isn’t the result of the .to(device) operation the same leaf variable but just in the GPU? Thanks.