code: def register(self, service, provider, singleton=False):
          
  
          def get_singleton(*args, **kwargs):
              result = self._get_singleton(service)
              if not result:
                  instantiator = self._get_instantiator(provider)
                  result = instantiator(*args, **kwargs)
                  self._set_singleton(service, result)
              return result
  
          # Providers are always registered in self.providers  as callable methods
  
          if not callable(provider):
              self._set_provider(service, lambda *args, **kwargs: provider)
          elif singleton:
              self._set_provider(service, get_singleton)
          else:
              self._set_provider(service, self._get_instantiator(provider))
docs: Registers a service provider for a given service.
  
          @param service
              A key that identifies the service being registered.
          @param provider
              This is either the service being registered, or a callable that will
              either instantiate it or return it.
          @param singleton
              Indicates that the service is to be registered as a singleton.
              This is only relevant if the provider is a callable. Services that
              are not callable will always be registered as singletons.