code: def _convert_to_cupy_ndarray(
      cuda_buffer: Union["cupy.ndarray", "rmm.DeviceBuffer"]
  ) -> "cupy.ndarray":
      if isinstance(cuda_buffer, cupy.ndarray):
          return cuda_buffer
  
      size = cuda_buffer.nbytes
      data = cuda_buffer.__cuda_array_interface__["data"][0]
      memory = cupy.cuda.UnownedMemory(data, size, cuda_buffer)
      ptr = cupy.cuda.MemoryPointer(memory, 0)
      return cupy.ndarray(shape=size, dtype="u1", memptr=ptr)
  
imports: from asyncio import StreamReader, StreamWriter
  from typing import Dict, List, Union
  import numpy
  from ....serialization.aio import BUFFER_SIZES_NAME
  from ....utils import lazy_import
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_to_cupy_ndarray(cuda_buffer) and returns: cupy, cuda_buffer