code: def rmm_cupy_ary(cupy_fn, *args, **kwargs):
      """
  
      Function to call CuPy functions with RMM memory management
  
      Parameters
      ----------
      cupy_fn : cupy function,
          CuPy function to execute, for example cp.array
  
      *args :
          Non keyword arguments to pass to the CuPy function
  
      **kwargs :
          Keyword named arguments to pass to the CuPy function
  
  
      .. note:: this function should be used if the result of cupy_fn creates
      a new array. Functions to create a new CuPy array by reference to
      existing device array (through __cuda_array_interface__) can be used
      directly.
  
      Examples
      --------
  
      >>> from cuml.common import rmm_cupy_ary
      >>> import cupy as cp
      >>>
      >>> # Get a new array filled with 0, column major
      >>> a = rmm_cupy_ary(cp.zeros, 5, order='F')
      >>> a
      array([0., 0., 0., 0., 0.])
  
      """
  
      if GPU_ENABLED:
          with cupy_using_allocator(rmm_cupy_allocator):
              result = cupy_fn(*args, **kwargs)
      else:
          result = cupy_fn(*args, **kwargs)
  
      return result
  
imports: import functools
  import operator
  import re
  from functools import wraps
  from cuml.internals.global_settings import GlobalSettings
  from cuml.internals.device_support import GPU_ENABLED
  from cuml.internals.mem_type import MemoryType
  from cuml.internals.output_type import INTERNAL_VALID_OUTPUT_TYPES, VALID_OUTPUT_TYPES
  from cuml.internals.safe_imports import cpu_only_import_from, gpu_only_import_from, UnavailableNullContext
label_desc: Use image node_id 4 for calling a global function with example usage: rmm_cupy_ary(cupy_fn) and returns: result