Could you update PyTorch to the latest stable version (1.8.1) or the nightly release and retry your code?
PS: you can post snippets by wrapping them into three backticks ```, which makes debugging easier and would allow indexing of the code snippet so that other users could use it in the forum search.