Remove hooks after deepcopying model

hello. From what I’ve seen the only possible way to remove registered hook it to keep its handle up to some moment and then call remove() on it but what to do if we registered hooks on model and then did deepcopy of it? Cause our kept handles are no longer valid for our copied model and there’s no way to obtain new handles from it while the old hooks are still working on “new” model.
Any ideas please?

def remove_forward_pre_hooks(model):
    for module in model.modules():
        module._forward_pre_hooks = None
    return model