How to Solve NameError: name 'optim' is not defined -- torch

Solution: Import the 'optim' module

# Add the following line to the top of your code
from torch import optim

 

For more information:
torch optim