Actually, looking at the stack trace I think you have a problem with local files:
the python tempfile library, when loading picks up your local random.py file as python’s original random library.
Can you import torch from another folder? If so, you will have to rename your random.py file I’m afraid.