code: def generate_data(
      n_voxels,
      n_timeframes,
      n_subjects,
      n_components,
      datadir,
      noise_level=0.1,
      input_format="array",
  ):
      n_sessions = len(n_timeframes)
      cumsum_timeframes = np.cumsum([0] + n_timeframes)
      slices_timeframes = [
          slice(cumsum_timeframes[i], cumsum_timeframes[i + 1])
          for i in range(n_sessions)
      ]
  
      # Create a Shared response S with K = 3
      theta = np.linspace(
          -4 * np.pi, 4 * np.pi, int(np.sum(n_timeframes))
      )
      z = np.linspace(-2, 2, int(np.sum(n_timeframes)))
      r = z**2 + 1
      x = r * np.sin(theta)
      y = r * np.cos(theta)
  
      S = np.vstack((x, y, z))
  
      # Generate fake data
      W = []
      X = []
      for subject in range(n_subjects):
          Q, R = np.linalg.qr(
              np.random.random((n_voxels, n_components))
          )
          W.append(Q.T)
          X_ = []
          for session in range(n_sessions):
              S_s = S[:, slices_timeframes[session]]
              S_s = S_s - np.mean(S_s, axis=1, keepdims=True)
              noise = noise_level * np.random.random(
                  (n_voxels, n_timeframes[session])
              )
              noise = noise - np.mean(noise, axis=1, keepdims=True)
              data = Q.dot(S_s) + noise
              X_.append(data)
          X.append(X_)
  
      # create paths such that paths[i, j] contains data
      # of subject i during session j
      S = [
          (S[:, s] - np.mean(S[:, s], axis=1, keepdims=True))
          for s in slices_timeframes
      ]
  
      if input_format == "array":
          paths = to_path(X, datadir)
          return paths, W, S
  
      elif input_format == "list_of_list":
          return X, W, S
  
      elif input_format == "list_of_array":
          return (
              [
                  np.concatenate(
                      [X[i][j].T for j in range(n_sessions)]
                  ).T
                  for i in range(n_subjects)
              ],
              W,
              S,
          )
      else:
          raise ValueError("Wrong input_format")
  
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 2 for calling a global function with example usage: generate_data(n_voxels, n_timeframes, n_subjects, n_components, datadir, noise_level, input_format) and returns: paths,  W,  S, X,  W,  S, unknown,  W,  S