code: def _ensure_future(coro_or_future, *, loop=None):
      if futures.isfuture(coro_or_future):
          if loop is not None and loop is not futures._get_loop(
              coro_or_future
          ):
              raise ValueError(
                  "The future belongs to a different loop than "
                  "the one specified as the loop argument"
              )
          return coro_or_future
      called_wrap_awaitable = False
      if not coroutines.iscoroutine(coro_or_future):
          if inspect.isawaitable(coro_or_future):
              coro_or_future = _wrap_awaitable(coro_or_future)
              called_wrap_awaitable = True
          else:
              raise TypeError(
                  "An asyncio.Future, a coroutine or an awaitable "
                  "is required"
              )
  
      if loop is None:
          loop = events._get_event_loop(stacklevel=4)
      try:
          return loop.create_task(coro_or_future)
      except RuntimeError:
          if not called_wrap_awaitable:
              coro_or_future.close()
          raise
  
imports: import concurrent.futures
  import contextvars
  import functools
  import inspect
  import itertools
  import types
  import warnings
  import weakref
  from types import GenericAlias
  from .None import base_tasks
  from .None import coroutines
  from .None import events
  from .None import exceptions
  from .None import futures
  from .coroutines import _is_coroutine
label_desc: Use image node_id 9 for calling a global function with example usage: _ensure_future(coro_or_future) and returns: coro_or_future, loop