code: def _validate_sparse(sparse):
      """
      'sparse' is a sparse representation of labelings
      It's either a numpy recarray, or castable as such via
      'arr.view(np.recarray)'
      where the data types are typed fields who's names are a subset of:
      set('label', 'c', 't', 'z', 'y', 'x')
      and where the data is a 1-dimensional array of tuples, matching the fields
  
      e.g.
      rec.array([(0, 0, 0, 1), (0, 1, 0, 1), (1, 0, 0, 1), (1, 1, 0, 1),
                 (0, 1, 0, 2), (0, 1, 1, 2), (1, 1, 0, 2), (1, 1, 1, 2)],
                dtype=[('z', '<u2'), ('y', '<u2'), ('x', '<u2'), ('label', 'u1')])
  
      Note that each field may have its own type, the tuple order matches the
      field order, each tuple is unique by at least one element, and there is
      no need (although permissable) to specify a field if it will be the same
      among all the data values (i.e. 'c' and 't' not specified above as they
      would all be '0')
  
      Note also there is no tuple who's 'label' value is '0' because including
      all '0' values would make 'sparse' equivilent in memory to 'dense',
      and including any '0' values at all would be including a non-label
      (i.e. background)
      """
      assert (
          type(sparse) == np.ndarray or type(sparse) == np.recarray
      ), "sparse must be ndarray or recarray"
  
      assert sparse.ndim == 1, "sparse mut be 1-dimensional"
  
      axes = sparse.dtype.names
  
      assert axes is not None, "sparse must have dtype fields"
  
      axes_set = set(axes)
      full_set = set(SPARSE_FIELDS)
  
      assert len(axes) == len(
          axes_set
      ), "duplicate dtype fields in sparse"
      assert axes_set.issubset(
          full_set
      ), "sparse has unknown dtype fields"
  
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 4 for calling a global function with example usage: _validate_sparse(sparse) without return types