code: def test_random_parcellation():
      """Test generation of random cortical parcellation."""
      pytest.importorskip("nibabel")
      hemi = "both"
      n_parcel = 50
      surface = "sphere.reg"
      subject = "sample_ds"
      rng = np.random.RandomState(0)
  
      # Parcellation
      labels = random_parcellation(
          subject,
          n_parcel,
          hemi,
          subjects_dir,
          surface=surface,
          random_state=rng,
      )
  
      # test number of labels
      assert_equal(len(labels), n_parcel)
      if hemi == "both":
          hemi = ["lh", "rh"]
      hemis = np.atleast_1d(hemi)
      for hemi in set(hemis):
          vertices_total = []
          for label in labels:
              if label.hemi == hemi:
                  # test that labels are not empty
                  assert len(label.vertices) > 0
  
                  # vertices of hemi covered by labels
                  vertices_total = np.append(
                      vertices_total, label.vertices
                  )
  
          # test that labels don't intersect
          assert_equal(
              len(np.unique(vertices_total)), len(vertices_total)
          )
  
          surf_fname = (
              subjects_dir / subject / "surf" / (hemi + "." + surface)
          )
          vert, _ = read_surface(surf_fname)
  
          # Test that labels cover whole surface
          assert_array_equal(
              np.sort(vertices_total), np.arange(len(vert))
          )
  
imports: import glob
  import os
  import pickle
  import shutil
  from itertools import product
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less, assert_equal
  from scipy import sparse
  from mne import grow_labels, labels_to_stc, morph_labels, random_parcellation, read_label, read_labels_from_annot, read_source_estimate, read_source_spaces, read_surface, spatial_tris_adjacency, split_label, stc_to_label, write_labels_to_annot
  from mne.datasets import testing
  from mne.label import Label, _blend_colors, _load_vert_pos, _n_colors, _read_annot, _read_annot_cands, label_sign_flip, select_sources
  from mne.source_estimate import mesh_edges
  from mne.source_space import SourceSpaces
  from mne.surface import _mesh_borders
  from mne.utils import _record_warnings, get_subjects_dir
label_desc: Use image node_id 20 for calling a global function with example usage: test_random_parcellation() without return types