docs: def provider(func=None, *, singleton=False, injector=None):
      """
      Decorator to mark a function as a provider.
  
      Args:
          singleton (bool): The returned value should be a singleton or shared
              instance. If False (the default) the provider function will be
              invoked again for every time it's needed for injection.
          injector (Injector): If provided, the function is immediately
              registered as a provider with the injector instance.
  
      Example:
          @diay.provider(singleton=True)
          def myfunc() -> MyClass:
              return MyClass(args)
      """
      def decorator(func):
          wrapped = _wrap_provider_func(func, {'singleton': singleton})
          if injector:
              injector.register_provider(wrapped)
          return wrapped
  
      if func:
          return decorator(func)
      return decorator