code: def test_reduced_data_srm():
      n_jobs = 1
      with tempfile.TemporaryDirectory() as datadir:
          np.random.seed(0)
  
          # We authorize different timeframes for different sessions but
          # they should be the same across subject
          n_voxels = 10
          n_timeframes = [25, 24]
          n_subjects = 5
          n_components = 3  # number of components used for SRM model
          n_sessions = len(n_timeframes)
  
          paths, W, S = generate_data(
              n_voxels,
              n_timeframes,
              n_subjects,
              n_components,
              datadir,
              0,
          )
  
          atlas = np.arange(1, n_voxels + 1)
          data = reduce_data(
              paths,
              atlas=atlas,
              n_jobs=n_jobs,
              low_ram=False,
              temp_dir=None,
          )
  
          # Test if shared response has the good shape
          shared_response_list = _reduced_space_compute_shared_response(
              data, reduced_basis_list=None, n_components=n_components
          )
          assert len(shared_response_list) == n_sessions
  
          for session in range(n_sessions):
              assert shared_response_list[session].shape == (
                  n_timeframes[session],
                  n_components,
              )
  
          # Test basis from shared response
          for i, sessions in enumerate(paths):
              basis = _compute_basis_subject_online(
                  sessions, [S[k].T for k in range(len(S))]
              )
              # test shape
              assert basis.shape == (n_components, n_voxels)
              # test orthogonality
              assert np.allclose(
                  basis.dot(basis.T), np.eye(n_components)
              )
              # test correctness
              assert_array_almost_equal(basis, W[i], 2)
  
          # Test reduced_data_shared_response
          shared_response_list = _reduced_space_compute_shared_response(
              data, reduced_basis_list=W, n_components=n_components
          )
          for session in range(n_sessions):
              S_real = np.mean(
                  [
                      data[i, session].dot(W[i].T)
                      for i in range(n_subjects)
                  ],
                  axis=0,
              )
              assert_array_almost_equal(
                  shared_response_list[session], S_real
              )
              assert_array_almost_equal(
                  shared_response_list[session], S[session].T
              )
  
          shared_response_list = fast_srm(
              data, n_components=n_components
          )
  
          for i, sessions in enumerate(paths):
              basis = _compute_basis_subject_online(
                  sessions, shared_response_list
              )
              for j, session in enumerate(sessions):
                  assert_array_almost_equal(
                      shared_response_list[j].dot(basis),
                      np.load(paths[i, j]).T,
                      3,
                  )
  
imports: import os
  import tempfile
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal
  from sklearn.exceptions import NotFittedError
  from brainiak.funcalign.fastsrm import FastSRM, _compute_and_save_corr_mat, _compute_and_save_subject_basis, _compute_basis_subject_online, _reduced_space_compute_shared_response, check_atlas, check_imgs, check_shared_response, create_temp_dir, fast_srm, reduce_data, safe_load
  from brainiak.funcalign.srm import DetSRM
label_desc: Use image node_id 10 for calling a global function with example usage: test_reduced_data_srm() without return types