code: def test_img_to_signals_maps_warnings(
      labeled_regions, fmri_img, shape_3d_default
  ):
      labels = list(range(N_REGIONS + 1))
      labels_data = get_data(labeled_regions)
      # Convert to maps
      maps_data = np.zeros(shape_3d_default + (N_REGIONS,))
      for n, l in enumerate(labels):
          if n == 0:
              continue
          maps_data[labels_data == l, n - 1] = 1
  
      maps_img = Nifti1Image(maps_data, labeled_regions.affine)
  
      mask_img = _create_mask_with_3_regions_from_labels_data(
          labels_data, labeled_regions.affine
      )
  
      # apply img_to_signals_maps with a masking,
      # containing only 3 regions, but
      # not keeping the masked maps
      with pytest.warns(
          UserWarning,
          match="After applying mask to the maps image, "
          "maps with the following indices were "
          r"removed: \{2, 3, 5, 6, 7\}. "
          "Out of 8 maps, the "
          "masked map image only contains "
          "3 maps.",
      ):
          maps_signals, maps_labels = img_to_signals_maps(
              fmri_img,
              maps_img,
              mask_img=mask_img,
              keep_masked_maps=False,
          )
  
      # only 3 regions must be kept, others must be removed
      assert maps_signals.shape == (N_TIMEPOINTS, 3)
      assert len(maps_labels) == 3
  
      # apply img_to_signals_labels with a masking,
      # containing only 3 regions, and
      # keeping the masked labels
      # test if the warning is raised
      with pytest.warns(
          DeprecationWarning,
          match='Applying "mask_img" before '
          "signal extraction may result in empty region signals in the "
          "output. These are currently kept. "
          "Starting from version 0.13, the default behavior will be "
          "changed to remove them by setting "
          '"keep_masked_maps=False". '
          '"keep_masked_maps" parameter will be removed '
          "in version 0.15.",
      ):
          maps_signals, maps_labels = img_to_signals_maps(
              fmri_img,
              maps_img,
              mask_img=mask_img,
              keep_masked_maps=True,
          )
  
      # all regions must be kept
      assert maps_signals.shape == (N_TIMEPOINTS, 8)
      assert len(maps_labels) == 8
  
imports: import warnings
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_almost_equal, assert_equal
  from nilearn._utils.data_gen import generate_fake_fmri, generate_labeled_regions, generate_maps, generate_timeseries
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.testing import write_imgs_to_path
  from nilearn.conftest import _affine_eye, _shape_3d_default
  from nilearn.image import get_data, new_img_like
  from nilearn.maskers import NiftiLabelsMasker
  from nilearn.regions.signal_extraction import _check_shape_and_affine_compatibility, _trim_maps, img_to_signals_labels, img_to_signals_maps, signals_to_img_labels, signals_to_img_maps
label_desc: Use image node_id 30 for calling a global function with example usage: test_img_to_signals_maps_warnings(labeled_regions, fmri_img, shape_3d_default) without return types