code: def salm2map(salm, 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