Not sure if that’s related to your problem, but similar issues originated in multiple PyTorch installatons (or some old, unused installs).
Could you check, if your current environment has some old PyTorch installs (in conda, pip, and build from source)?