code: def sum(input, labels=None, index=None):
      """Calculates the sum of the values of an n-D image array, optionally
         at specified sub-regions.
  
      Args:
          input (cupy.ndarray): Nd-image data to process.
          labels (cupy.ndarray or None): Labels defining sub-regions in `input`.
              If not None, must be same shape as `input`.
          index (cupy.ndarray or None): `labels` to include in output. If None
              (default), all values where `labels` is non-zero are used.
  
      Returns:
         sum (cupy.ndarray): sum of values, for each sub-region if
         `labels` and `index` are specified.
  
      Notes:
          This is an alias for `cupyx.scipy.ndimage.sum_labels` kept for
          backwards compatibility reasons. For new code please prefer
          `sum_labels`.
  
      .. seealso:: :func:`scipy.ndimage.sum`
      """
      return sum_labels(input, labels, index)
  
imports: import warnings
  import numpy
  import cupy
  from cupy import _core
  from cupy import _util
label_desc: Use image node_id 14 for calling a global function with example usage: sum(input, labels, index) and returns: sum_labels