code: def get_resource(self, type: Type[T_Resource], name: str = 'default') -> Optional[T_Resource]:
          
          assert check_argument_types()
          self._check_closed()
          key = (type, name)
  
          # First check if there's already a matching resource in this context
          resource = self._resources.get(key)
          if resource is not None:
              return resource.value_or_factory
  
          # Next, check if there's a resource factory available on the context chain
          resource = next((ctx._resource_factories[key] for ctx in self.context_chain
                           if key in ctx._resource_factories), None)
          if resource is not None:
              return resource.generate_value(self)
  
          # Finally, check parents for a matching resource
          return next((ctx._resources[key].value_or_factory for ctx in self.context_chain
                       if key in ctx._resources), None)
docs: Look up a resource in the chain of contexts.
  
          :param type: type of the requested resource
          :param name: name of the requested resource
          :return: the requested resource, or ``None`` if none was available