I don’t know which libraries you are using and cannot reproduce the issue using torchvision, so could you update the code snippet with all missing libs and use random tensors so that we could try to reproduce the issue, please?
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.