code: def _cancel_all_tasks(loop):
      to_cancel = tasks.all_tasks(loop)
      if not to_cancel:
          return
  
      for task in to_cancel:
          task.cancel()
  
      loop.run_until_complete(
          tasks.gather(*to_cancel, return_exceptions=True)
      )
  
      for task in to_cancel:
          if task.cancelled():
              continue
          if task.exception() is not None:
              loop.call_exception_handler(
                  {
                      "message": "unhandled exception during asyncio.run() shutdown",
                      "exception": task.exception(),
                      "task": task,
                  }
              )
  
imports: import contextvars
  import enum
  import functools
  import threading
  import signal
  import sys
  from .None import coroutines
  from .None import events
  from .None import exceptions
  from .None import tasks
label_desc: Use image node_id 2 for calling a global function with example usage: _cancel_all_tasks(loop) without return types