code: def _validate_labels(labels):
      """
      A 'labels' matrix is another, more constrained, dense representation
  
      It is strictly 2- or 3-dimensional, of shape: (y, x) or (z, y, x)
      A single 'labels' matrix does not allow for overlapping labels within it
  
      It is essentially a 'dense' of shape (1, 1, 1, 1, y, x), but squeezed
      such that the ('label_idx', 'c', 't', 'z') axes are removed
  
      For a 'dense' with shape (2+, 1, 1, 1, y, x), a 'label_set' can be
      constructed (see 'convert_dense_to_label_set' for more details)
      """
      assert type(labels) == np.ndarray, "labels must be ndarray"
      assert (
          labels.ndim == 2 or labels.ndim == 3
      ), "labels must be 2- or 3-dimensional"
  
imports: from enum import Enum
  import numpy
  from numpy.random.mtrand import RandomState
  import scipy.sparse
  import centrosome.index
label_desc: Use image node_id 3 for calling a global function with example usage: _validate_labels(labels) without return types