<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register(name, fn=None):
 """ Decorator to register a function as a hook Register hook for ``hook_name``. Can be used as a decorator:: @register('hook_name') pass or as a function call:: pass register('hook_name', my_hook) :param name: str Name of the hook/callback to register it as :param fn: function to register in the hook/callback :return: function Decorator if applied as a decorator """

    def _hook_add(func):
        if name not in _hooks:
            logger.debug("Creating new hook %s" % name)
            _hooks[name] = []

        logger.debug('Registering hook %s for function %s' % (name, fn))
        _hooks[name].append(func)

    if fn is None:
        # Behave like a decorator
        def decorator(func):
            _hook_add(func)
            return func
        return decorator
    else:
        # Behave like a function, just register hook
        _hook_add(fn)