code: def test_color_3d_mask():
      msk = np.zeros((20, 21, 22))
      msk[2:-2, 2:-2, 2:-2] = 1
  
      rng = np.random.default_rng(0)
      img = np.zeros((20, 21, 22, 3))
      slices = []
      for dim_size in msk.shape:
          midpoint = dim_size // 2
          slices.append((slice(None, midpoint), slice(midpoint, None)))
      slices = list(product(*slices))
      colors = list(product(*(([0, 1],) * 3)))
      for s, c in zip(slices, colors):
          img[s] = c
      img += 0.01 * rng.normal(size=img.shape)
      np.clip(img, 0, 1, out=img)
  
      seg = slic(img, sigma=0, n_segments=8, mask=msk)
  
      # we expect 8 segments + masked area
      assert_equal(len(np.unique(seg)), 9)
      for s, c in zip(slices, range(1, 9)):
          assert_equal(seg[s][2:-2, 2:-2, 2:-2], c)
  
imports: from itertools import product
  import numpy
  import pytest
  from numpy.testing import assert_equal
  from skimage import data, filters, img_as_float
  from skimage._shared.testing import run_in_parallel, expected_warnings
  from skimage.segmentation import slic
label_desc: Use image node_id 23 for calling a global function with example usage: test_color_3d_mask() without return types