code: def test_check_shape_first_level_models():
      shapes, rk = [(7, 8, 9, 15)], 3
      (
          mask,
          fmri_data,
          design_matrices,
      ) = generate_fake_fmri_data_and_design(shapes, rk)
      list_of_flm = [
          FirstLevelModel(mask_img=mask, subject_label=f"sub-{i}").fit(
              fmri_data[0], design_matrices=design_matrices[0]
          )
          for i in range(3)
      ]
      # should pass
      _check_input_as_first_level_model(
          second_level_input=list_of_flm, none_confounds=False
      )
  
      # add a model with a different shape
      # should raise an error
      shapes, rk = [(8, 9, 10, 15)], 3
      (
          mask,
          fmri_data,
          design_matrices,
      ) = generate_fake_fmri_data_and_design(shapes, rk)
      list_of_flm.append(
          FirstLevelModel(mask_img=mask, subject_label="sub-4").fit(
              fmri_data[0], design_matrices=design_matrices[0]
          )
      )
  
      with pytest.raises(
          ValueError,
          match="All first level models must have the same shape",
      ):
          _check_input_as_first_level_model(
              second_level_input=list_of_flm, none_confounds=False
          )
  
imports: import os
  from pathlib import Path
  import numpy
  import pandas
  import pytest
  from nibabel import Nifti1Image, load
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from scipy import stats
  from nilearn._utils import testing
  from nilearn._utils.data_gen import generate_fake_fmri_data_and_design, write_fake_bold_img, write_fake_fmri_data_and_design
  from nilearn.glm.first_level import FirstLevelModel, run_glm
  from nilearn.glm.second_level import SecondLevelModel, non_parametric_inference
  from nilearn.glm.second_level.second_level import _check_confounds, _check_design_matrix, _check_effect_maps, _check_first_level_contrast, _check_input_as_first_level_model, _check_output_type, _check_second_level_input, _infer_effect_maps, _process_second_level_input_as_dataframe, _process_second_level_input_as_firstlevelmodels, _sort_input_dataframe
  from nilearn.image import concat_imgs, get_data, new_img_like, smooth_img
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 9 for calling a global function with example usage: test_check_shape_first_level_models() without return types