code: def save_as_nifti_file(data: np.ndarray, affine: np.ndarray,
                         path: Union[str, Path]) -> None:
      
      if not isinstance(path, str):
          path = str(path)
      img = Nifti1Pair(data, affine)
      nib.nifti1.save(img, path)
docs: Create a Nifti file and save it.
  
      Parameters
      ----------
      data
          Brain data.
      affine
          Affine of the image, usually inherited from an existing image.
      path
          Output filename.