code: def using_allocator(allocator=None):
      """Sets a thread-local allocator for GPU memory inside
         context manager
  
      Args:
          allocator (function): CuPy memory allocator. It must have the same
              interface as the :func:`cupy.cuda.alloc` function, which takes the
              buffer size as an argument and returns the device buffer of that
              size. When ``None`` is specified, raw memory allocator will be
              used (i.e., memory pool is disabled).
      """
      # Note: cupy/memory.pyx would be the better place to implement this
      # function but `contextmanager` decoration doesn't behave well in Cython.
      if allocator is None:
          allocator = memory._malloc
      previous_allocator = memory._get_thread_local_allocator()
      memory._set_thread_local_allocator(allocator)
      try:
          yield
      finally:
          memory._set_thread_local_allocator(previous_allocator)
  
imports: import contextlib
  import warnings
  import cupy
  from cupy._environment import get_cuda_path
  from cupy._environment import get_nvcc_path
  from cupy._environment import get_rocm_path
  from cupy._environment import get_hipcc_path
  from cupy.cuda import compiler
  from cupy.cuda import device
  from cupy.cuda import function
  from cupy.cuda import memory
  from cupy.cuda import memory_hook
  from cupy.cuda import memory_hooks
  from cupy.cuda import pinned_memory
  from cupy.cuda import profiler
  from cupy.cuda import stream
  from cupy.cuda import texture
  from cupy_backends.cuda.api import driver
  from cupy_backends.cuda.api import runtime
  from cupy_backends.cuda.libs import nvrtc
  from cupy.cuda import cub
  from cupy.cuda.device import Device
  from cupy.cuda.device import get_cublas_handle
  from cupy.cuda.device import get_device_id
  from cupy.cuda.function import Function
  from cupy.cuda.function import Module
  from cupy.cuda.memory import alloc
  from cupy.cuda.memory import BaseMemory
  from cupy.cuda.memory import malloc_managed
  from cupy.cuda.memory import malloc_async
  from cupy.cuda.memory import ManagedMemory
  from cupy.cuda.memory import Memory
  from cupy.cuda.memory import MemoryAsync
  from cupy.cuda.memory import MemoryPointer
  from cupy.cuda.memory import MemoryPool
  from cupy.cuda.memory import MemoryAsyncPool
  from cupy.cuda.memory import PythonFunctionAllocator
  from cupy.cuda.memory import CFunctionAllocator
  from cupy.cuda.memory import set_allocator
  from cupy.cuda.memory import get_allocator
  from cupy.cuda.memory import UnownedMemory
  from cupy.cuda.memory_hook import MemoryHook
  from cupy.cuda.pinned_memory import alloc_pinned_memory
  from cupy.cuda.pinned_memory import PinnedMemory
  from cupy.cuda.pinned_memory import PinnedMemoryPointer
  from cupy.cuda.pinned_memory import PinnedMemoryPool
  from cupy.cuda.pinned_memory import set_pinned_memory_allocator
  from cupy.cuda.stream import Event
  from cupy.cuda.stream import get_current_stream
  from cupy.cuda.stream import get_elapsed_time
  from cupy.cuda.stream import Stream
  from cupy.cuda.stream import ExternalStream
  from cupy.cuda.graph import Graph
label_desc: Use image node_id 4 for calling a global function with example usage: using_allocator(allocator) without return types