code: def test_infer_repetition_time_from_dataset(tmp_path):
      """Test inferring repetition time from the BIDS dataset.
  
      When using create_fake_bids_dataset the value is 1.5 secs by default
      in the raw dataset.
      When using add_metadata_to_bids_dataset the value is 2.0 secs.
      """
      bids_path = create_fake_bids_dataset(
          base_dir=tmp_path,
          n_sub=1,
          n_ses=1,
          tasks=["main"],
          n_runs=[1],
      )
  
      t_r = infer_repetition_time_from_dataset(
          bids_path=tmp_path / bids_path, filters=[("task", "main")]
      )
  
      expected_t_r = 1.5
      assert t_r == expected_t_r
  
      expected_t_r = 2.0
      add_metadata_to_bids_dataset(
          bids_path=tmp_path / bids_path,
          metadata={"RepetitionTime": expected_t_r},
      )
  
      t_r = infer_repetition_time_from_dataset(
          bids_path=tmp_path / bids_path / "derivatives",
          filters=[("task", "main"), ("run", "01")],
      )
  
      assert t_r == expected_t_r
  
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 2 for calling a global function with example usage: test_infer_repetition_time_from_dataset(tmp_path) without return types