code: def save(img, filename):
      """Save NIfTI2 single or pair to `filename`
  
      Parameters
      ----------
      filename : str
          filename to which to save image
      """
      try:
          Nifti2Image.instance_to_filename(img, filename)
      except ImageFileError:
          Nifti2Pair.instance_to_filename(img, filename)
  
imports: import numpy
  from .analyze import AnalyzeHeader
  from .batteryrunners import Report
  from .filebasedimages import ImageFileError
  from .nifti1 import Nifti1Header, Nifti1Image, Nifti1Pair
  from .spatialimages import HeaderDataError
label_desc: Use image node_id 2 for calling a global function with example usage: save(img, filename) without return types