code: def unravel_index(indices, dims, order="C"):
      """Converts array of flat indices into a tuple of coordinate arrays.
  
      Args:
          indices (cupy.ndarray): An integer array whose elements are indices
              into the flattened version of an array of dimensions :obj:`dims`.
          dims (tuple of ints): The shape of the array to use for unraveling
              indices.
          order ('C' or 'F'): Determines whether the indices should be viewed as
              indexing in row-major (C-style) or column-major (Fortran-style)
              order.
  
      Returns:
          tuple of ndarrays:
          Each array in the tuple has the same shape as the indices array.
  
      Examples
      --------
      >>> cupy.unravel_index(cupy.array([22, 41, 37]), (7, 6))
      (array([3, 6, 6]), array([4, 5, 1]))
      >>> cupy.unravel_index(cupy.array([31, 41, 13]), (7, 6), order='F')
      (array([3, 6, 6]), array([4, 5, 1]))
  
      .. warning::
  
          This function may synchronize the device.
  
      .. seealso:: :func:`numpy.unravel_index`, :func:`ravel_multi_index`
  
      """
      order = "C" if order is None else order.upper()
      if order == "C":
          dims = reversed(dims)
      elif order == "F":
          pass
      else:
          raise ValueError("order not understood")
  
      if not cupy.can_cast(indices, cupy.int64, "same_kind"):
          raise TypeError(
              "Iterator operand 0 dtype could not be cast "
              "from dtype('{}') to dtype('{}') "
              "according to the rule 'same_kind'".format(
                  indices.dtype, cupy.int64().dtype
              )
          )
  
      if (indices < 0).any():  # synchronize!
          raise ValueError("invalid entry in index array")
  
      unraveled_coords = []
      for dim in dims:
          unraveled_coords.append(indices % dim)
          indices = indices // dim
  
      if (indices > 0).any():  # synchronize!
          raise ValueError("invalid entry in index array")
  
      if order == "C":
          unraveled_coords = reversed(unraveled_coords)
      return tuple(unraveled_coords)
  
imports: import functools
  import numbers
  import operator
  import numpy
  import cupy
  from cupy._creation import from_data
  from cupy._manipulation import join
label_desc: Use image node_id 4 for calling a global function with example usage: unravel_index(indices, dims, order) and returns: tuple