updated the code to work with the new torch version.