This PR fixes a RuntimeError: OrderedDict mutated during iteration error
This code worked in Python 3.9.16.
I guess that the error occurs when using Python 3.10.12.
The error is caused by modifying an OrderedDict during iteration, which is prohibited in Python 3.10.12.
Changes:
Created an temporary dictionary updated_state_dict to store modifications and update the original state_dict after the iteration.
This PR fixes a
RuntimeError: OrderedDict mutated during iteration error
This code worked inPython 3.9.16
. I guess that the error occurs when usingPython 3.10.12
. The error is caused by modifying anOrderedDict
during iteration, which is prohibited inPython 3.10.12
.Changes:
updated_state_dict
to store modifications and update the originalstate_dict
after the iteration.