You need to take a look at  PyTorch 0.4.0 Migration Guide 316 to make sure the changes are taken into consideration. In general,  I don’t thin it is a good idea to merge two code from different version with each other