code: def centroid(image, *, spacing=None):
      """Return the (weighted) centroid of an image.
  
      Parameters
      ----------
      image : array
          The input image.
      spacing: tuple of float, shape (ndim,)
          The pixel spacing along each axis of the image.
  
      Returns
      -------
      center : tuple of float, length ``image.ndim``
          The centroid of the (nonzero) pixels in ``image``.
  
      Examples
      --------
      >>> image = np.zeros((20, 20), dtype=np.float64)
      >>> image[13:17, 13:17] = 0.5
      >>> image[10:12, 10:12] = 1
      >>> centroid(image)
      array([13.16666667, 13.16666667])
      """
      M = moments_central(
          image, center=(0,) * image.ndim, order=1, spacing=spacing
      )
      center = (
          M[
              tuple(np.eye(image.ndim, dtype=int))
          ]  # array of weighted sums
          # for each axis
          / M[(0,) * image.ndim]
      )  # weighted sum of all points
      return center
  
file_path: scikit-image/skimage/measure/_moments.py
imports: import itertools
  import numpy
  from .._shared.utils import _supported_float_type, check_nD
  from .None import _moments_cy
  from ._moments_analytical import moments_raw_to_central
label_desc: Use image node_id 7 for calling a global function with example usage: centroid(image) and returns: center