code: def check_shared_response(
      shared_response,
      aggregate="mean",
      n_components=None,
      input_shapes=None,
  ):
      """
      Check that shared response has valid input and turn it into
      a session-wise shared response
  
      Returns
      -------
      added_session: bool
          True if an artificial sessions was added to match the list of
          session input type for shared_response
      reshaped_shared_response: list of arrays
          shared response (reshaped to match the list of session input)
      """
      # Depending on aggregate and shape of input we infer what to do
      if isinstance(shared_response, list):
          assert_non_empty_list(shared_response, "shared_response")
          if isinstance(shared_response[0], list):
              if aggregate == "mean":
                  raise ValueError(
                      "self.aggregate has value 'mean' but "
                      "shared response is a list of list. This is "
                      "incompatible"
                  )
              return False, _check_shared_response_list_of_list(
                  shared_response, n_components, input_shapes
              )
          elif isinstance(shared_response[0], np.ndarray):
              if aggregate == "mean":
                  return False, _check_shared_response_list_sessions(
                      shared_response, n_components, input_shapes
                  )
              else:
                  return True, _check_shared_response_list_subjects(
                      shared_response, n_components, input_shapes
                  )
          else:
              raise ValueError(
                  "shared_response is a list but "
                  "shared_response[0] is neither a list "
                  "or an array. This is invalid."
              )
      elif isinstance(shared_response, np.ndarray):
          return True, _check_shared_response_array(
              shared_response, n_components, input_shapes
          )
      else:
          raise ValueError(
              "shared_response should be either "
              "a list or an array but is of type %s"
              % type(shared_response)
          )
  
imports: import hashlib
  import logging
  import os
  import numpy
  import scipy
  from joblib import Parallel, delayed
  from brainiak.funcalign.srm import DetSRM
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.exceptions import NotFittedError
  import uuid
label_desc: Use image node_id 21 for calling a global function with example usage: check_shared_response(shared_response, aggregate, n_components, input_shapes) and returns: False,  _check_shared_response_list_of_list, True,  _check_shared_response_array, False,  _check_shared_response_list_sessions, True,  _check_shared_response_list_subjects