code: def async_run(coroutine):
      """Attaches to running event loop or creates a new one to execute a
      coroutine.
      .. seealso::
           https://github.com/snakemake/snakemake/issues/1105
           https://stackoverflow.com/a/65696398
      """
      try:
          return asyncio.run(coroutine)
      except RuntimeError as e:
          coroutine.close()
          raise WorkflowError(
              "Error running coroutine in event loop. Snakemake currently does not "
              "support being executed from an already running event loop. "
              "If you run Snakemake e.g. from a Jupyter notebook, make sure to spawn a "
              "separate process for Snakemake.",
              e,
          )
  
imports: import contextlib
  import itertools
  import math
  import operator
  import platform
  import hashlib
  import inspect
  import sys
  import uuid
  import os
  import asyncio
  import collections
  from pathlib import Path
  from snakemake._version import get_versions
  from snakemake_interface_common.exceptions import WorkflowError
label_desc: Use image node_id 5 for calling a global function with example usage: async_run(coroutine) and returns: asyncio