code: def percent_used_mem_on_dev(
      device: Union[ivy.Device, ivy.NativeDevice],
      /,
      *,
      process_specific: bool = False,
  ) -> float:
      """Get the percentage used memory for a given device string. In case of
      CPU, the used RAM is returned.
  
      Parameters
      ----------
      device
          The device string to convert to native device handle.
      process_specific
          Whether the check the memory used by this python process alone. Default is
          False.
  
      Returns
      -------
      ret
          The percentage used memory on the device.
  
      Examples
      --------
      >>> x = ivy.percent_used_mem_on_dev("cpu", process_specific = False)
      >>> print(x)
      94.036902561555
  
      >>> x = ivy.percent_used_mem_on_dev("cpu", process_specific = True)
      >>> print(x)
      0.7024003467681645
  
      >>> x = ivy.as_native_dev("gpu:0")
      >>> y = ivy.percent_used_mem_on_dev(x, process_specific = False)
      >>> print(y)
      0.7095597456708771
      """
      ivy.clear_cached_mem_on_dev(device)
      if "gpu" in device:
          handle = _get_nvml_gpu_handle(device)
          info = pynvml.nvmlDeviceGetMemoryInfo(handle)
          if process_specific:
              pid = os.getpid()
              for (
                  process
              ) in pynvml.nvmlDeviceGetComputeRunningProcesses(handle):
                  if process.pid == pid:
                      return (process.usedGpuMemory / info.total) * 100
          return (info.used / info.total) * 100
      elif device == "cpu":
          vm = psutil.virtual_memory()
          if process_specific:
              return (
                  psutil.Process(os.getpid()).memory_info().rss
                  / vm.total
              ) * 100
          return (1 - (vm.available / vm.total)) * 100
      else:
          raise ivy.utils.exceptions.IvyException(
              'Invalid device string input, must be on the form "gpu:idx" or "cpu", but'
              f" found {device}"
          )
  
imports: import os
  import gc
  import abc
  import math
  import psutil
  import warnings
  import types
  from typing import Type, Optional, Tuple
  from typing import Union, Callable, Iterable, Any
  import ivy
  from ivy.func_wrapper import handle_out_argument, to_native_arrays_and_back, inputs_to_native_arrays, handle_nestable, handle_array_like_without_promotion, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 15 for calling a global function with example usage: percent_used_mem_on_dev() and returns: unknown, unknown, unknown, unknown