Encountering this problem is generally due to a problem with the environment configuration, and a new Python has been installed.
So you need to configure the environment at this time
File-->Settings-->python interpreter
Choose the environment where you have installed pytorch