If you are not using the latest PyTorch release, could you update to the latest stable version and rerun the code, please?
If you are still facing this error, could you post an executable code snippet to reproduce it so that we could debug it?