code: def test_fs_xfm(subject, tmp_path):
      """Test reading and writing of Freesurfer transforms."""
      fname = (
          data_path
          / "subjects"
          / subject
          / "mri"
          / "transforms"
          / "talairach.xfm"
      )
      xfm, kind = _read_fs_xfm(str(fname))
      if subject == "fsaverage":
          assert_allclose(
              xfm, np.eye(4), atol=1e-5
          )  # fsaverage is in MNI
      assert kind == "MNI Transform File"
      fname_out = tmp_path / "out.xfm"
      _write_fs_xfm(fname_out, xfm, kind)
      xfm_read, kind_read = _read_fs_xfm(str(fname_out))
      assert kind_read == kind
      assert_allclose(xfm, xfm_read, rtol=1e-5, atol=1e-5)
      # Some wacky one
      xfm[:3] = np.random.RandomState(0).randn(3, 4)
      _write_fs_xfm(fname_out, xfm, "foo")
      xfm_read, kind_read = _read_fs_xfm(str(fname_out))
      assert kind_read == "foo"
      assert_allclose(xfm, xfm_read, rtol=1e-5, atol=1e-5)
      # degenerate conditions
      with open(fname_out, "w") as fid:
          fid.write("foo")
      with pytest.raises(ValueError, match="Failed to find"):
          _read_fs_xfm(str(fname_out))
      _write_fs_xfm(fname_out, xfm[:2], "foo")
      with pytest.raises(ValueError, match="Could not find"):
          _read_fs_xfm(str(fname_out))
  
imports: import itertools
  import os
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal, assert_array_less, assert_equal
  import mne
  from mne import read_trans, write_trans
  from mne.datasets import testing
  from mne.fixes import _get_img_fdata
  from mne.io import read_info
  from mne.transforms import _angle_between_quats, _average_quats, _cart_to_sph, _compute_r2, _euler_to_quat, _find_trans, _find_vector_rotation, _fit_matched_points, _get_trans, _MatchedDisplacementFieldInterpolator, _pol_to_cart, _quat_real, _quat_to_affine, _quat_to_euler, _read_fs_xfm, _sph_to_cart, _topo_to_sph, _validate_pipeline, _write_fs_xfm, apply_trans, combine_transforms, get_ras_to_neuromag_trans, invert_transform, quat_to_rot, rot_to_quat, rotation, rotation3d, rotation3d_align_z_axis, rotation_angles, translation
  from mne.transforms import _SphericalSurfaceWarp
label_desc: Use image node_id 18 for calling a global function with example usage: test_fs_xfm(subject, tmp_path) without return types