code: def test_marching_cubes(dtype, value, smooth, order):
      """Test creating surfaces via marching cubes."""
      pytest.importorskip("pyvista")
      data = np.zeros((50, 50, 50), dtype=dtype, order=order)
      data[20:30, 20:30, 20:30] = value
      level = [value]
      out = _marching_cubes(data, level, smooth=smooth)
      assert len(out) == 1
      verts, triangles = out[0]
      # verts and faces are rather large so use checksum
      rtol = 1e-2 if smooth else 1e-9
      assert_allclose(
          verts.sum(axis=0), [14700, 14700, 14700], rtol=rtol
      )
      tri_sum = triangles.sum(axis=0).tolist()
      assert tri_sum in (
          [350588, 360865, 363402],
          [350408, 359867, 364089],
      )
      # test fill holes
      data[24:27, 24:27, 24:27] = 0
      verts, triangles = _marching_cubes(
          data, level, smooth=smooth, fill_hole_size=2
      )[0]
      # check that no surfaces in the middle
      assert (
          np.linalg.norm(verts - np.array([25, 25, 25]), axis=1).min()
          > 4
      )
      # problematic values
      with pytest.raises(TypeError, match="1D array-like"):
          _marching_cubes(data, ["foo"])
      with pytest.raises(TypeError, match="1D array-like"):
          _marching_cubes(data, [[1]])
      with pytest.raises(TypeError, match="1D array-like"):
          _marching_cubes(data, [1.0])
      with pytest.raises(ValueError, match="must be between 0"):
          _marching_cubes(data, [1], smooth=1.0)
      with pytest.raises(ValueError, match="3D data"):
          _marching_cubes(data[0], [1])
  
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 11 for calling a global function with example usage: test_marching_cubes(dtype, value, smooth, order) without return types