def METHOD_NAME(
    resource_def: "ResourceDefinition", init_context: Optional["UnboundInitResourceContext"]
) -> Any:
    from ..execution.context.init import UnboundInitResourceContext
    from .resource_definition import ResourceDefinition, has_at_least_one_parameter
    check.inst_param(resource_def, "resource_def", ResourceDefinition)
    check.opt_inst_param(init_context, "init_context", UnboundInitResourceContext)
    if not resource_def.resource_fn:
        return None
    _init_context = _check_invocation_requirements(resource_def, init_context)
    resource_fn = resource_def.resource_fn
    val_or_gen = (
        resource_fn(_init_context)
        if has_at_least_one_parameter(resource_fn)
        else resource_fn()  # type: ignore  # (strict type guard)
    )
    if inspect.isgenerator(val_or_gen):
        @contextmanager
        def _wrap_gen():
            try:
                val = next(val_or_gen)
                yield val
            except StopIteration:
                check.failed("Resource generator must yield one item.")
        return _wrap_gen()
    else:
        return val_or_gen