code: def test_region_names():
      """Test region_names_ attribute in NiftiLabelsMasker"""
      shape = (13, 11, 12, 3)
      affine = np.eye(4)
      fmri_img, _ = data_gen.generate_random_img(shape, affine=affine)
      labels_img = data_gen.generate_labeled_regions(
          shape[:3],
          affine=affine,
          n_regions=7,
      )
  
      # define region_names
      region_names = ["background"] + [
          "region_" + str(i + 1) for i in range(7)
      ]
  
      masker = NiftiLabelsMasker(
          labels_img,
          labels=region_names,
          resampling_target=None,
      )
      _ = masker.fit().transform(fmri_img)
  
      region_names_after_fit = [
          masker.region_names_[i] for i in masker.region_names_
      ]
      region_names_after_fit.sort()
      region_names.sort()
      region_names.pop(region_names.index("background"))
      assert region_names_after_fit == region_names
  
imports: import warnings
  import nibabel
  import numpy
  import pytest
  from nilearn._utils import data_gen, testing
  from nilearn._utils.exceptions import DimensionError
  from nilearn.image import get_data
  from nilearn.maskers import NiftiLabelsMasker, NiftiMasker
label_desc: Use image node_id 10 for calling a global function with example usage: test_region_names() without return types