code: def register_hooks(func, hooks, obj):
      
      for name, args, kwargs in hooks:
          hook = getattr(obj, name)
          force_call = kwargs.pop("_force_call", False)
          if force_call or len(args) > 0 or len(kwargs) > 0:
              hook = hook(*args, **kwargs)
          hook(func)
docs: Register func on obj via hooks.
      Hooks should be a tuple of (name, args, kwargs) where
      name is a method name of obj. If args or kwargs are not empty,
      the method will be called first and expect a new function as return.