Of what type is x? Is it a numpy array?
If so, what dtype does it have?
A small side note: based on your code it looks like your pytorch version is < 0.4.0. You should consider updating to the latest stable release. Have a look at the website 2 for install instructions.