code: def test_fmri_inputs_errors(tmp_path, confounds):
      # prepare fake data
      shapes = ((7, 8, 9, 10),)
      _, FUNCFILE, _ = write_fake_fmri_data_and_design(
          shapes, file_path=tmp_path
      )
      FUNCFILE = FUNCFILE[0]
      func_img = load(FUNCFILE)
      n_samples = func_img.shape[-1]
      des = pd.DataFrame(np.ones((n_samples, 1)), columns=["a"])
      des_fname = str(tmp_path / "design.csv")
      des.to_csv(des_fname)
  
      # prepare correct input first level models
      flm = FirstLevelModel(subject_label="01").fit(
          FUNCFILE, design_matrices=des
      )
  
      # test first level model requirements
      with pytest.raises(TypeError, match="second_level_input must be"):
          SecondLevelModel().fit(flm)
      with pytest.raises(TypeError, match="at least two"):
          SecondLevelModel().fit([flm])
  
      # test first_level_conditions, confounds, and design
      flms = [flm, flm, flm]
      with pytest.raises(
          ValueError, match="confounds must be a pandas DataFrame"
      ):
          SecondLevelModel().fit(flms, ["", []])
      with pytest.raises(
          ValueError, match="confounds must be a pandas DataFrame"
      ):
          SecondLevelModel().fit(flms, [])
      with pytest.raises(
          ValueError, match="confounds must be a pandas DataFrame"
      ):
          SecondLevelModel().fit(flms, confounds["conf1"])
      with pytest.raises(
          ValueError, match="design matrix must be a pandas DataFrame"
      ):
          SecondLevelModel().fit(flms, None, [])
  
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 31 for calling a global function with example usage: test_fmri_inputs_errors(tmp_path, confounds) without return types