code: def save_generator(ttype):
      """Generate a saving function that performs a file extension
      check to restrict the user to a single file format.
  
      Parameters
      ----------
      ttype : string
          Extension of the file format that requires a saver
      Returns
      -------
      output : function
          Function (save_tractogram) that handle only one file format
      """
  
      def f_gen(sft, filename, bbox_valid_check=True):
          _, extension = os.path.splitext(filename)
          if not extension == ttype:
              msg = f"This function can only save {ttype} file, "
              msg += (
                  "for more general cases, use save_tractogram instead."
              )
              raise ValueError(msg)
          save_tractogram(
              sft, filename, bbox_valid_check=bbox_valid_check
          )
  
      f_gen.__doc__ = save_tractogram.__doc__.replace(
          "in any format (trk/tck/vtk/vtp/fib/dpy)",
          f"of the {ttype} format",
      )
      return f_gen
  
file_path: dipy/dipy/io/streamline.py
imports: from copy import deepcopy
  import logging
  import os
  import time
  import nibabel
  from nibabel.streamlines import detect_format
  from nibabel.streamlines.tractogram import Tractogram
  import numpy
  import trx.trx_file_memmap
  from dipy.io.stateful_tractogram import Origin, Space, StatefulTractogram
  from dipy.io.vtk import save_vtk_streamlines, load_vtk_streamlines
  from dipy.io.dpy import Dpy
  from dipy.io.utils import create_tractogram_header, is_header_compatible
label_desc: Use image node_id 4 for calling a global function with example usage: save_generator(ttype) and returns: f_gen