code: def test_io_surface(tmp_path):
      """Test reading and writing of Freesurfer surface mesh files."""
      pytest.importorskip("nibabel")
      fname_quad = (
          data_path / "subjects" / "bert" / "surf" / "lh.inflated.nofix"
      )
      fname_tri = (
          data_path / "subjects" / "sample" / "bem" / "inner_skull.surf"
      )
      for fname in (fname_quad, fname_tri):
          with _record_warnings():  # no volume info
              pts, tri, vol_info = read_surface(
                  fname, read_metadata=True
              )
          write_surface(
              tmp_path / "tmp",
              pts,
              tri,
              volume_info=vol_info,
              overwrite=True,
          )
          with _record_warnings():  # no volume info
              c_pts, c_tri, c_vol_info = read_surface(
                  tmp_path / "tmp", read_metadata=True
              )
          assert_array_equal(pts, c_pts)
          assert_array_equal(tri, c_tri)
          assert_equal(object_diff(vol_info, c_vol_info), "")
          if (
              fname != fname_tri
          ):  # don't bother testing wavefront for the bigger
              continue
  
          # Test writing/reading a Wavefront .obj file
          write_surface(
              tmp_path / "tmp.obj",
              pts,
              tri,
              volume_info=None,
              overwrite=True,
          )
          c_pts, c_tri = read_surface(
              tmp_path / "tmp.obj", read_metadata=False
          )
          assert_array_equal(pts, c_pts)
          assert_array_equal(tri, c_tri)
  
      # reading patches (just a smoke test, let the flatmap viz tests be more
      # complete)
      fname_patch = (
          data_path
          / "subjects"
          / "fsaverage"
          / "surf"
          / "rh.cortex.patch.flat"
      )
      _read_patch(fname_patch)
  
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne import decimate_surface, dig_mri_distances, get_montage_volume_labels, pick_types, read_surface, write_surface
  from mne._fiff.constants import FIFF
  from mne.channels import make_dig_montage
  from mne.datasets import testing
  from mne.io import read_info
  from mne.surface import _compute_nearest, _get_ico_surface, _marching_cubes, _normal_orth, _project_onto_surface, _read_patch, _tessellate_sphere, _voxel_neighbors, fast_cross_3d, get_head_surf, get_meg_helmet_surf, read_curvature
  from mne.transforms import _get_trans
  from mne.utils import _record_warnings, catch_logging, object_diff, requires_freesurfer
label_desc: Use image node_id 5 for calling a global function with example usage: test_io_surface(tmp_path) without return types