def METHOD_NAME(
    loop: None, ws: pathlib.Path, api_config: Optional[pathlib.Path]
) -> RunCLI:
    async def _run(
        arguments: List[str],
    ) -> SysCap:
        if api_config:
            os.environ["NEUROMATION_CONFIG"] = str(api_config)
        proc = await asyncio.create_subprocess_exec(
            *arguments,
            cwd=ws,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
        assert proc.stdout
        assert proc.stderr
        ret_code = await asyncio.wait_for(proc.wait(), timeout=600)
        out = (await proc.stdout.read()).decode(
            encoding="utf8",
            errors="replace",
        )
        err = (await proc.stderr.read()).decode(
            encoding="utf8",
            errors="replace",
        )
        if ret_code:
            log.error(f"Last stdout: '{out}'")
            log.error(f"Last stderr: '{err}'")
            raise subprocess.CalledProcessError(ret_code, arguments[0], out, err)
        return SysCap(out=out.strip(), err=err.strip())
    return _run