code: def test_save_glm_to_bids_contrast_definitions(
      tmp_path_factory, two_runs_model, contrasts, prefix
  ):
      """Test that save_glm_to_bids operates on different contrast definitions as
      expected.
  
      - Test string-based contrasts and undefined contrast types
  
      This test reuses code from
      nilearn.glm.tests.test_first_level.test_high_level_glm_one_session.
      """
      tmpdir = tmp_path_factory.mktemp(
          "test_save_glm_to_bids_contrast_definitions"
      )
  
      EXPECTED_FILENAME_ENDINGS = [
          "dataset_description.json",
          ("contrast-aaaMinusBbb_stat-effect_statmap.nii.gz"),
          "contrast-aaaMinusBbb_stat-p_statmap.nii.gz",
          "contrast-aaaMinusBbb_stat-t_statmap.nii.gz",
          ("contrast-aaaMinusBbb_stat-variance_statmap.nii.gz"),
          "contrast-aaaMinusBbb_stat-z_statmap.nii.gz",
          "run-1_contrast-aaaMinusBbb_design.svg",
          "run-1_design.svg",
          "run-1_design.tsv",
          "run-2_contrast-aaaMinusBbb_design.svg",
          "run-2_design.svg",
          "run-2_design.tsv",
          "stat-errorts_statmap.nii.gz",
          "stat-rSquare_statmap.nii.gz",
          "statmap.json",
      ]
  
      save_glm_to_bids(
          model=two_runs_model,
          contrasts=contrasts,
          contrast_types=None,
          out_dir=tmpdir,
          prefix=prefix,
      )
  
      for fname in EXPECTED_FILENAME_ENDINGS:
          if fname != "dataset_description.json" and isinstance(
              prefix, str
          ):
              fname = (
                  prefix + fname
                  if prefix.endswith("_")
                  else f"{prefix}_{fname}"
              )
          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 13 for calling a global function with example usage: test_save_glm_to_bids_contrast_definitions(tmp_path_factory, two_runs_model, contrasts, prefix) without return types