it is because you are changing parameters some where before  calling optimizer.step(), the give code isn’t that detailed to figure it out but may be the problem is arising due to some step in self.entire_l(),
it would be helpful if you provide with entire_l method.