Okay, so it is a PyTorch internal thing? Because i think that i do not need to redefine the closure function. The closure uses self.model which is a reference to model and whenever i change the object under the name self.model the closure function evaluates the new assigned model.