Solved by KFrank in post #2 
              
              
                Hi Nihal! 

print (type (optimizer).__name__)

will do what you want. 
(This is generally true for python objects, and is not specific to pytorch.) 
Best. 
K. Frank