def optional_arguments(d):
    """
    Decorate the input decorator d to accept optional arguments.
    """
    def wrapped_decorator(*args):
        if len(args) == 1 and callable(args[0]):
            return d(args[0])
        else:
            def real_decorator(decoratee):
                return d(decoratee, *args)
            return real_decorator
    return wrapped_decorator