def METHOD_NAME(
    run_config: Mapping[str, object],
    ephemeral_job: JobDefinition,
    instance: Optional[DagsterInstance],
    output_capturing_enabled: bool,
    raise_on_error: bool,
    run_tags: Optional[Mapping[str, str]] = None,
    run_id: Optional[str] = None,
    asset_selection: Optional[FrozenSet[AssetKey]] = None,
) -> ExecuteInProcessResult:
    job_def = ephemeral_job
    job = InMemoryJob(job_def)
    _check_top_level_inputs(job_def)
    execution_plan = create_execution_plan(
        job,
        run_config=run_config,
        instance_ref=instance.get_ref() if instance and instance.is_persistent else None,
    )
    output_capture: Dict[StepOutputHandle, Any] = {}
    with ephemeral_instance_if_missing(instance) as execute_instance:
        run = execute_instance.create_run_for_job(
            job_def=job_def,
            run_config=run_config,
            tags={**job_def.tags, **(run_tags or {})},
            run_id=run_id,
            asset_selection=asset_selection,
            execution_plan=execution_plan,
        )
        run_id = run.run_id
        execute_run_iterable = ExecuteRunWithPlanIterable(
            execution_plan=execution_plan,
            iterator=job_execution_iterator,
            execution_context_manager=PlanOrchestrationContextManager(
                context_event_generator=orchestration_context_event_generator,
                job=job,
                execution_plan=execution_plan,
                dagster_run=run,
                instance=execute_instance,
                run_config=run_config,
                executor_defs=None,
                output_capture=output_capture if output_capturing_enabled else None,
                raise_on_error=raise_on_error,
            ),
        )
        event_list = list(execute_run_iterable)
        run = execute_instance.get_run_by_id(run_id)
    return ExecuteInProcessResult(
        job_def=ephemeral_job,
        event_list=event_list,
        dagster_run=cast(DagsterRun, run),
        output_capture=output_capture,
    )