You are using 1.9.0, which had a missing shape check after porting some internal kernels to the structured kernel implementations, so you would need to update PyTorch.
In your initial post you’ve mentioned PyTorch 1.10.0, which should not suffer from this issue anymore.