docs: def salm2map(salm, s, lmax, Ntheta, Nphi):
      """Convert mode weights of spin-weighted function to values on a grid
  
      Parameters
      ----------
      salm : array_like, complex, shape (..., (lmax+1)**2)
          Input array representing mode weights of the spin-weighted function.  This array may be
          multi-dimensional, where initial dimensions may represent different times, for example, or
          separate functions on the sphere.  The final dimension should give the values of the mode
          weights, in the order described below in the 'Notes' section.
      s : int or array, int, shape (...)
          Spin weight of the function.  If `salm` is multidimensional and this is an array, its
          dimensions must match the first dimensions of `salm`, and the different values are the spin
          weights of the different functions represented by those dimensions.  Otherwise, if `salm` is
          multidimensional and `s` is a single integer, all functions are assumed to have the same
          spin weight.
      lmax : int
          The largest `ell` value present in the input array.
      Ntheta : int
          Number of points in the output grid along the polar angle.
      Nphi : int
          Number of points in the output grid along the azimuthal angle.
  
  
      Returns
      -------
      map : ndarray, complex, shape (..., Ntheta, Nphi)
          Values of the spin-weighted function on grid points of the sphere.  This array is shaped
          like the input `salm` array, but has one extra dimension.  The final two dimensions describe
          the values of the function on the sphere.
  
  
      See also
      --------
      spinsfast.map2salm : Roughly the inverse of this function.
  
  
      Notes
      -----
  
      The input `salm` data should be given in increasing order of `ell` value, always starting with
      (ell, m) = (0, 0) even if `s` is nonzero, proceeding to (1, -1), (1, 0), (1, 1), etc.
      Explicitly, the ordering should match this:
  
          [f_lm(ell, m) for ell in range(lmax+1) for m in range(-ell, ell+1)]
  
      The input is converted to a contiguous complex numpy array if necessary.
  
      The output data are presented on this grid of spherical coordinates:
  
          np.array([[f(theta, phi)
                     for phi in np.linspace(0.0, 2*np.pi, num=2*lmax+1, endpoint=False)]
                    for theta in np.linspace(0.0, np.pi, num=2*lmax+1, endpoint=True)])
  
      Note that `map2salm` and `salm2map` are not true inverses of each other for several reasons.
      First, modes with `ell < |s|` should always be zero; they are simply assumed to be zero on input
      to `salm2map`.  It is also possible to define a `map` function that violates this assumption --
      for example, having a nonzero average value over the sphere, if the function has nonzero spin
      `s`, this is impossible.  Also, it is possible to define a map of a function with so much
      angular dependence that it cannot be captured with the given `lmax` value.  For example, a
      discontinuous function will never be perfectly resolved.
  
  
      Example
      -------
      >>> s = -2
      >>> lmax = 8
      >>> Ntheta = Nphi = 2*lmax + 1
      >>> modes = np.zeros(spinsfast.N_lm(lmax), dtype=np.complex128)
      >>> modes[spinsfast.lm_ind(2, 2, 8)] = 1.0
      >>> values = spinsfast.salm2map(modes, s, lmax, Ntheta, Nphi)
  
      """
      if Ntheta < 2 or Nphi < 1:
          raise ValueError("Input values of Ntheta={0} and Nphi={1} ".format(Ntheta, Nphi)
                           + "are not allowed; they must be greater than 1 and 0, respectively.")
      if lmax < 1:
          raise ValueError("Input value of lmax={0} ".format(lmax)
                           + "is not allowed; it must be greater than 0 and should be greater "
                           + "than |s|={0}.".format(abs(s)))
      import numpy as np
      salm = np.ascontiguousarray(salm, dtype=np.complex128)
      if salm.shape[-1] < N_lm(lmax):
          raise ValueError("The input `salm` array of shape {0} is too small for the stated `lmax` of {1}.  ".format(salm.shape, lmax)
                           + "Perhaps you forgot to include the (zero) modes with ell<|s|.")
      map = np.empty(salm.shape[:-1]+(Ntheta, Nphi), dtype=np.complex128)
      if salm.ndim>1:
          s = np.ascontiguousarray(s, dtype=np.intc)
          if s.ndim != salm.ndim-1 or np.product(s.shape) != np.product(salm.shape[:-1]):
              s = s*np.ones(salm.shape[:-1], dtype=np.intc)
          _multi_salm2map(salm, map, s, lmax, Ntheta, Nphi)
      else:
          _salm2map(salm, map, s, lmax, Ntheta, Nphi)
      return map