code: def decorator(caller, _func=None):
      
      if _func is not None:  # return a decorated function
          # this is obsolete behavior; you should use decorate instead
          return decorate(_func, caller)
      # else return a decorator function
      if inspect.isclass(caller):
          name = caller.__name__.lower()
          callerfunc = get_init(caller)
          doc = 'decorator(%s) converts functions/generators into ' \
              'factories of %s objects' % (caller.__name__, caller.__name__)
          fun = getfullargspec(callerfunc).args[1]  # second arg
      elif inspect.isfunction(caller):
          if caller.__name__ == '<lambda>':
              name = '_lambda_'
          else:
              name = caller.__name__
          callerfunc = caller
          doc = caller.__doc__
          fun = getfullargspec(callerfunc).args[0]  # first arg
      else:  # assume caller is an object with a __call__ method
          name = caller.__class__.__name__.lower()
          callerfunc = caller.__call__.__func__
          doc = caller.__call__.__doc__
          fun = getfullargspec(callerfunc).args[1]  # second arg
      evaldict = callerfunc.__globals__.copy()
      evaldict['_call_'] = caller
      evaldict['_decorate_'] = decorate
      return FunctionMaker.create(
          '%s(%s)' % (name, fun),
          'return _decorate_(%s, _call_)' % fun,
          evaldict, call=caller, doc=doc, module=caller.__module__,
          __wrapped__=caller)
docs: decorator(caller) converts a caller function into a decorator