code: def cart2sphere(x, y, z):
      r"""Return angles for Cartesian 3D coordinates `x`, `y`, and `z`
  
      See doc for ``sphere2cart`` for angle conventions and derivation
      of the formulae.
  
      $0\le\theta\mathrm{(theta)}\le\pi$ and $-\pi\le\phi\mathrm{(phi)}\le\pi$
  
      Parameters
      ----------
      x : array_like
         x coordinate in Cartesian space
      y : array_like
         y coordinate in Cartesian space
      z : array_like
         z coordinate
  
      Returns
      -------
      r : array
         radius
      theta : array
         inclination (polar) angle
      phi : array
         azimuth angle
  
      """
      r = np.sqrt(x * x + y * y + z * z)
      theta = np.arccos(np.divide(z, r, where=r > 0))
      theta = np.where(r > 0, theta, 0.0)
      phi = np.arctan2(y, x)
      r, theta, phi = np.broadcast_arrays(r, theta, phi)
      return r, theta, phi
  
imports: import itertools
  import math
  import numpy
  import numpy.linalg
label_desc: Use image node_id 2 for calling a global function with example usage: cart2sphere(x, y, z) and returns: r,  theta,  phi