code: def test_save_glm_to_bids_second_level(tmp_path_factory):
      """Test save_glm_to_bids on a SecondLevelModel.
  
      This test reuses code from
      nilearn.glm.tests.test_second_level.test_high_level_glm_with_paths.
      """
      tmpdir = tmp_path_factory.mktemp(
          "test_save_glm_to_bids_second_level"
      )
  
      EXPECTED_FILENAMES = [
          "dataset_description.json",
          "task-nback_contrast-effectsOfInterest_design.svg",
          "task-nback_contrast-effectsOfInterest_stat-F_statmap.nii.gz",
          "task-nback_contrast-effectsOfInterest_stat-effect_statmap.nii.gz",
          "task-nback_contrast-effectsOfInterest_stat-p_statmap.nii.gz",
          "task-nback_contrast-effectsOfInterest_stat-variance_statmap.nii.gz",
          "task-nback_contrast-effectsOfInterest_stat-z_statmap.nii.gz",
          "task-nback_design.svg",
          "task-nback_design.tsv",
          "task-nback_stat-errorts_statmap.nii.gz",
          "task-nback_stat-rSquare_statmap.nii.gz",
          "task-nback_statmap.json",
      ]
  
      shapes = ((7, 8, 9, 1),)
      rk = 3
      mask, func_img, _ = generate_fake_fmri_data_and_design(
          shapes,
          rk,
      )
      func_img = func_img[0]
  
      # Ordinary Least Squares case
      model = SecondLevelModel(mask_img=mask, minimize_memory=False)
  
      # fit model
      Y = [func_img] * 4
      X = pd.DataFrame([[1]] * 4, columns=["intercept"])
      model = model.fit(Y, design_matrix=X)
  
      contrasts = {
          "effects of interest": np.eye(
              len(model.design_matrix_.columns)
          )[0],
      }
      contrast_types = {"effects of interest": "F"}
  
      save_glm_to_bids(
          model=model,
          contrasts=contrasts,
          contrast_types=contrast_types,
          out_dir=tmpdir,
          prefix="task-nback",
      )
  
      for fname in EXPECTED_FILENAMES:
          full_filename = os.path.join(tmpdir, fname)
          assert os.path.isfile(full_filename)
  
imports: import json
  import os
  import numpy
  import pandas
  import pytest
  from nilearn._utils.data_gen import add_metadata_to_bids_dataset, create_fake_bids_dataset, generate_fake_fmri_data_and_design
  from nilearn.glm.first_level import FirstLevelModel
  from nilearn.glm.second_level import SecondLevelModel
  from nilearn.interfaces.bids import get_bids_files, parse_bids_filename, save_glm_to_bids
  from nilearn.interfaces.bids.query import _get_metadata_from_bids, infer_repetition_time_from_dataset, infer_slice_timing_start_time_from_dataset
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 14 for calling a global function with example usage: test_save_glm_to_bids_second_level(tmp_path_factory) without return types