The recursively_collect_optim_state_dict function has a mutable default argument. Due to the weird/magical/confusing ways that Python works it seems like the default argument itself gets updated causing all future calls to this function to have a pre-populated visited set.
Hello!
The
recursively_collect_optim_state_dict
function has a mutable default argument. Due to the weird/magical/confusing ways that Python works it seems like the default argument itself gets updated causing all future calls to this function to have a pre-populatedvisited
set.Relevant stackoverflow link for this issue: https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument?fbclid=IwAR1pR_luIkKqRzeLoDBYC38hUt3Qxnc_3wtnZfLAbEoAsiaFNuM1mFiJNbI
https://github.com/NM512/dreamerv3-torch/blob/2c7a81a0e2f5f0c7659ba73b0ddbedf2a7e2ecf4/tools.py#L965-L967
I propose the following change to avoid this issue: