code: def test_connected_label_regions_unknonw_labels(
      labels_img, affine_eye, shape_3d_default
  ):
      """If unknown/negative integers are provided as labels in labels_img, \
      we raise an error and test the same whether error is raised.
  
      Introduce data type of float
  
      See issue: https://github.com/nilearn/nilearn/issues/2580
      """
      labels_data = get_data(labels_img)
  
      labels_data = np.zeros(shape_3d_default, dtype=np.float32)
      h0, h1, h2 = (x // 2 for x in shape_3d_default)
      labels_data[:h0, :h1, :h2] = 1
      labels_data[:h0, :h1, h2:] = 2
      labels_data[:h0, h1:, :h2] = 3
      labels_data[:h0, h1:, h2:] = -4
      labels_data[h0:, :h1, :h2] = 5
      labels_data[h0:, :h1, h2:] = 6
      labels_data[h0:, h1:, :h2] = np.nan
      labels_data[h0:, h1:, h2:] = np.inf
  
      neg_labels_img = Nifti1Image(labels_data, affine_eye)
  
      with pytest.raises(ValueError):
          connected_label_regions(labels_img=neg_labels_img)
  
      # If labels_img provided is 4D Nifti image, then test whether error is
      # raised or not. Since this function accepts only 3D image.
      labels_4d_data = np.zeros((shape_3d_default) + (2,))
      labels_data[h0:, h1:, :h2] = 0
      labels_data[h0:, h1:, h2:] = 0
      labels_4d_data[..., 0] = labels_data
      labels_4d_data[..., 1] = labels_data
      labels_img_4d = Nifti1Image(labels_4d_data, affine_eye)
  
      with pytest.raises(DimensionError):
          connected_label_regions(labels_img=labels_img_4d)
  
imports: import numpy
  import pytest
  from nibabel import Nifti1Image
  from scipy.ndimage import label
  from nilearn._utils.data_gen import generate_labeled_regions, generate_maps
  from nilearn._utils.exceptions import DimensionError
  from nilearn.conftest import _affine_eye, _img_4d_zeros, _shape_3d_default
  from nilearn.image import get_data
  from nilearn.regions import RegionExtractor, connected_label_regions, connected_regions
  from nilearn.regions.region_extractor import _remove_small_regions, _threshold_maps_ratio
label_desc: Use image node_id 28 for calling a global function with example usage: test_connected_label_regions_unknonw_labels(labels_img, affine_eye, shape_3d_default) without return types