code: def io_tractogram(extension):
      with TemporaryDirectory() as tmp_dir:
          fname = "test.{}".format(extension)
          fpath = os.path.join(tmp_dir, fname)
  
          in_affine = np.eye(4)
          in_dimensions = np.array([50, 50, 50])
          in_voxel_sizes = np.array([2, 1.5, 1.5])
          in_affine = np.dot(
              in_affine, np.diag(np.r_[in_voxel_sizes, 1])
          )
          nii_header = create_nifti_header(
              in_affine, in_dimensions, in_voxel_sizes
          )
  
          sft = StatefulTractogram(
              STREAMLINES, nii_header, space=Space.RASMM
          )
          save_tractogram(sft, fpath, bbox_valid_check=False)
  
          if extension in ["trk", "trx"]:
              reference = "same"
          else:
              reference = nii_header
  
          sft = load_tractogram(
              fpath, reference, bbox_valid_check=False
          )
          affine, dimensions, voxel_sizes, _ = sft.space_attributes
  
          npt.assert_array_equal(in_affine, affine)
          npt.assert_array_equal(in_voxel_sizes, voxel_sizes)
          npt.assert_array_equal(in_dimensions, dimensions)
          npt.assert_equal(len(sft), len(STREAMLINES))
          npt.assert_array_almost_equal(
              sft.streamlines[1], STREAMLINE, decimal=4
          )
  
imports: import os
  from tempfile import TemporaryDirectory
  from urllib.error import URLError, HTTPError
  from dipy.data import get_fnames
  from dipy.io.streamline import load_tractogram, save_tractogram, load_trk, save_trk
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.utils import create_nifti_header
  from dipy.io.vtk import save_vtk_streamlines, load_vtk_streamlines
  from dipy.tracking.streamline import Streamlines
  import numpy
  import numpy.testing
  import pytest
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 3 for calling a global function with example usage: io_tractogram(extension) without return types