It doesn’t seem like a Docker issue to me. Commands are just running during Docker build, but running the commands interactively in a container or even without containers would most likely give you the same result.
ONe of the installed packages could install a different python version as dependency, although the symbolic links should still work. Check the installed pyzhon versions and it would help if you could share how you came to the conclusion that Python is not 3.7, what command you ran. YOu mention Pytorch in the title, not Python, for example. If you get wrong pytorch version, that is a different issue which could be caused by an incorrect requirements.txt.