code: def _patch_task():
      """Patch the Task's step and enter/leave methods to make it reentrant."""
  
      def step(task, exc=None):
          curr_task = curr_tasks.get(task._loop)
          try:
              step_orig(task, exc)
          finally:
              if curr_task is None:
                  curr_tasks.pop(task._loop, None)
              else:
                  curr_tasks[task._loop] = curr_task
  
      Task = asyncio.Task
      if hasattr(Task, "_nest_patched"):
          return
      if sys.version_info >= (3, 7, 0):
  
          def enter_task(loop, task):
              curr_tasks[loop] = task
  
          def leave_task(loop, task):
              curr_tasks.pop(loop, None)
  
          asyncio.tasks._enter_task = enter_task
          asyncio.tasks._leave_task = leave_task
          curr_tasks = asyncio.tasks._current_tasks
          step_orig = Task._Task__step
          Task._Task__step = step
      else:
          curr_tasks = Task._current_tasks
          step_orig = Task._step
          Task._step = step
      Task._nest_patched = True
  
file_path: catboost/contrib/python/nest-asyncio/nest_asyncio.py
imports: import asyncio
  import asyncio.events
  import os
  import sys
  import threading
  from contextlib import contextmanager, suppress
  from heapq import heappop
label_desc: Use image node_id 5 for calling a global function with example usage: _patch_task() without return types