code: def test_save_spaces():
      # Test that intended output spaces get set into nifti
      data = np.random.normal(size=(2, 3, 4))
      aff = np.diag([2.0, 3, 4, 1])
      in_cs = CS("ijk")
      for label, csm in (
          ("scanner", scanner_csm),
          ("aligned", aligned_csm),
          ("talairach", talairach_csm),
          ("mni", mni_csm),
      ):
          img = Image(data, AT(in_cs, csm(3), aff))
          ni_img = nipy2nifti(img)
          assert (
              get_header(ni_img).get_value_label("sform_code") == label
          )
  
imports: import warnings
  from copy import copy
  import nibabel
  import numpy
  import pytest
  from nibabel.affines import from_matvec
  from nibabel.spatialimages import HeaderDataError
  from numpy.testing import assert_array_equal
  from ...core.api import AffineTransform
  from ...core.api import CoordinateSystem
  from ...core.api import Image
  from ...core.reference.spaces import aligned_csm, mni_csm, scanner_csm, talairach_csm, unknown_csm, unknown_space, vox2mni
  from ...testing import anatfile, funcfile
  from ..files import load
  from ..nibcompat import get_affine, get_header
  from ..nifti_ref import NiftiError, nifti2nipy, nipy2nifti
label_desc: Use image node_id 14 for calling a global function with example usage: test_save_spaces() without return types