code: def run_sync(coro: Callable[..., Awaitable[T]]) -> Callable[..., T]:
      """Wraps coroutine in a function that blocks until it has executed.
  
      Parameters
      ----------
      coro : coroutine-function
          The coroutine-function to be executed.
  
      Returns
      -------
      result :
          Whatever the coroutine-function returns.
      """
  
      if not inspect.iscoroutinefunction(coro):
          raise AssertionError
  
      def wrapped(*args: Any, **kwargs: Any) -> Any:
          name = threading.current_thread().name
          inner = coro(*args, **kwargs)
          try:
              # If a loop is currently running in this thread,
              # use a task runner.
              asyncio.get_running_loop()
              if name not in _runner_map:
                  _runner_map[name] = _TaskRunner()
              return _runner_map[name].run(inner)
          except RuntimeError:
              pass
  
          # Run the loop for this thread.
          # In Python 3.12, a deprecation warning is raised, which
          # may later turn into a RuntimeError.  We handle both
          # cases.
          with warnings.catch_warnings():
              warnings.simplefilter("ignore", DeprecationWarning)
              try:
                  loop = asyncio.get_event_loop()
              except RuntimeError:
                  loop = asyncio.new_event_loop()
                  asyncio.set_event_loop(loop)
              return loop.run_until_complete(inner)
  
      wrapped.__doc__ = coro.__doc__
      return wrapped
  
imports: from __future__ import annotations
  import asyncio
  import atexit
  import errno
  import inspect
  import sys
  import threading
  import warnings
  from pathlib import Path
  from types import FrameType
  from typing import Any, Awaitable, Callable, TypeVar, cast
label_desc: Use image node_id 5 for calling a global function with example usage: run_sync(coro) and returns: wrapped, _runner_map, loop