Is deep copy needed when doing load_state_dict?

I want to copy Module1's params into Module2, but I want the 2 modules to be independent thereafter.

Is it enough to do Module2.load_state_dict(Module1.state_dict())?

Or do I have to do Module2.load_state_dict(copy.deepcopy(Module1.state_dict()))?

According to the documentation, module.load_state_dict copies parameters and buffers from state_dict into this module and its descendants.
So you don’t need to copy again.