Can you please mention if there is an error, or what is the behavior.
Also, please try:
momentum = getattr(optimizer, 'momentum')
momentum = 0.9

I am new to PyTorch, but I presume if the __eq__ operator is custom defined by PyTorch to do more than just assigning, if it also edits some computation graph elements, this should work.