Correct way of freezing layers

Depending how this custom method is implemented, you might want to call detach() on the parameters additionally or just use copy.deepcopy(model).