code: def get_device_memory_pointer(array):
      xp = chainer.backend.get_array_module(array)
      array = xp.ascontiguousarray(array)
  
      if xp is np:
          return array
      elif xp is cp:
          return ctypes.cast(
              array.data.ptr,
              ctypes.POINTER(ctypes.c_ubyte * array.nbytes),
          ).contents
      elif xp is chx:
          backend_name = array.device.backend.name
          if backend_name not in ["native", "cuda"]:
              raise ValueError(
                  "{} is an unsupported backend".format(backend_name)
              )
          return ctypes.cast(
              array.data_ptr,
              ctypes.POINTER(ctypes.c_ubyte * array.nbytes),
          ).contents
      else:
          raise ValueError(
              "{} is from an unsupported array module".format(
                  type(array)
              )
          )
  
imports: import ctypes
  import mpi4py.MPI
  import numpy
  from chainermn.communicators import _communication_utility
  import chainer.backends
  import chainerx
label_desc: Use image node_id 8 for calling a global function with example usage: get_device_memory_pointer(array) and returns: array, ctypes, ctypes