Unfortunately, the code is not executable so I can’t debug it but can give my best guesses.
It seems you are storing the entire model instead of the state_dict, which I would not recommend as I’ve seen it failing in various ways.
Store the state_dict instead, recreate the model instance, and load the state_dict back afterwards.