code: def _runner_with_protocol(
      protocol: type[WitlessProtocol],
  ) -> ThreadedRunner:
      return ThreadedRunner(
          cmd=py2cmd("for i in range(5): print(i)"),
          protocol_class=protocol,
          stdin=None,
      )
  
imports: from __future__ import annotations
  import random
  import threading
  import time
  from threading import Thread
  from datalad.tests.utils_pytest import assert_raises
  from ..coreprotocols import StdOutCapture
  from ..nonasyncrunner import ThreadedRunner
  from ..protocol import GeneratorMixIn, WitlessProtocol
  from .utils import py2cmd
label_desc: Use image node_id 1 for calling a global function with example usage: _runner_with_protocol(protocol) and returns: ThreadedRunner