def METHOD_NAME(tmpdir, num_reals, num_jobs, job_sleep=0):
    builder = ert.ensemble_evaluator.EnsembleBuilder()
    with tmpdir.as_cwd():
        ext_job_list = []
        for job_index in range(0, num_jobs):
            ext_job_config = Path(tmpdir) / f"EXT_JOB_{job_index}"
            with open(ext_job_config, "w", encoding="utf-8") as f:
                f.write(f"EXECUTABLE ext_{job_index}.py\n")
            ext_job_exec = Path(tmpdir) / f"ext_{job_index}.py"
            with open(ext_job_exec, "w", encoding="utf-8") as f:
                f.write(
                    "#!/usr/bin/env python\n"
                    "import time\n"
                    "\n"
                    'if __name__ == "__main__":\n'
                    f'    print("stdout from {job_index}")\n'
                    f"    time.sleep({job_sleep})\n"
                    f"    with open('status.txt', 'a', encoding='utf-8'): pass\n"
                )
            mode = os.stat(ext_job_exec).st_mode
            mode |= stat.S_IXUSR | stat.S_IXGRP
            os.chmod(ext_job_exec, stat.S_IMODE(mode))
            ext_job_list.append(
                ExtJob.from_config_file(
                    str(ext_job_config), name=f"ext_job_{job_index}"
                )
            )
        @dataclass
        class RunArg:
            iens: int
        for iens in range(0, num_reals):
            run_path = Path(tmpdir / f"real_{iens}")
            os.mkdir(run_path)
            with open(run_path / "jobs.json", "w", encoding="utf-8") as f:
                json.dump(
                    {
                        "jobList": [
                            _dump_ext_job(ext_job, index)
                            for index, ext_job in enumerate(ext_job_list)
                        ],
                    },
                    f,
                )
            step = (
                ert.ensemble_evaluator.StepBuilder()
                .set_id("0")
                .set_job_name("job dispatch")
                .set_job_script("job_dispatch.py")
                .set_max_runtime(10000)
                .set_run_arg(Mock(iens=iens))
                .set_done_callback(lambda _, _b: (LoadStatus.LOAD_SUCCESSFUL, ""))
                .set_exit_callback(lambda _, _b: (LoadStatus.LOAD_FAILURE, ""))
                # the first callback_argument is expected to be a run_arg
                # from the run_arg, the queue wants to access the iens prop
                .set_callback_arguments((RunArg(iens), None))
                .set_run_path(run_path)
                .set_num_cpu(1)
                .set_name("dummy step")
                .set_dummy_io()
            )
            for index, job in enumerate(ext_job_list):
                step.add_job(
                    ert.ensemble_evaluator.LegacyJobBuilder()
                    .set_id(str(index))
                    .set_index(str(index))
                    .set_name(f"dummy job {index}")
                    .set_ext_job(job)
                )
            builder.add_realization(
                ert.ensemble_evaluator.RealizationBuilder()
                .active(True)
                .set_iens(iens)
                .add_step(step)
            )
    analysis_config = Mock()
    analysis_config.get_stop_long_running = Mock(return_value=False)
    analysis_config.minimum_required_realizations = 0
    ecl_config = Mock()
    ecl_config.assert_restart = Mock()
    builder.set_legacy_dependencies(
        queue_config,
        analysis_config,
    )
    builder.set_id("0")
    return builder