class_docstr: Semi-Supervised Shared Response Model (SS-SRM)
  
  Given multi-subject data, factorize it as a shared response S among all
  subjects and an orthogonal transform W per subject, using also labeled
  data to train a Multinomial Logistic Regression (MLR) classifier (with
  l2 regularization) in a semi-supervised manner:
  
  .. math::
      (1-\alpha) Loss_{SRM}(W_i,S;X_i)
      + \alpha/\gamma Loss_{MLR}(\theta, bias; {(W_i^T \times Z_i, y_i})
      + R(\theta)
      :label: sssrm-eq
  
  (see Equations (1) and (4) in [Turek2016]_).
  
  Parameters
  ----------
  
  n_iter : int, default: 10
      Number of iterations to run the algorithm.
  
  features : int, default: 50
      Number of features to compute.
  
  gamma : float, default: 1.0
      Regularization parameter for the classifier.
  
  alpha : float, default: 0.5
      Balance parameter between the SRM term and the MLR term.
  
  rand_seed : int, default: 0
      Seed for initializing the random number generator.
  
  
  Attributes
  ----------
  
  w_ : list of array, element i has shape=[voxels_i, features]
      The orthogonal transforms (mappings) for each subject.
  
  s_ : array, shape=[features, samples]
      The shared response.
  
  theta_ : array, shape=[classes, features]
      The MLR class plane parameters.
  
  bias_ : array, shape=[classes]
      The MLR class biases.
  
  classes_ : array of int, shape=[classes]
      Mapping table for each classes to original class label.
  
  random_state_: `RandomState`
      Random number generator initialized using rand_seed
  
  Note
  ----
  
      The number of voxels may be different between subjects. However, the
      number of samples for the alignment data must be the same across
      subjects. The number of labeled samples per subject can be different.
  
      The Semi-Supervised Shared Response Model is approximated using the
      Block-Coordinate Descent (BCD) algorithm proposed in [Turek2016]_.
  
      This is a single node version.
class_docstr_tok: ["Semi-Supervised","Shared","Response","Model","(","SS-SRM",")","Given","multi-subject","data",",","factorize","it","as","a","shared","response","S","among","all","subjects","and","an","orthogonal","transform","W","per","subject",",","using","also","labeled","data","to","train","a","Multinomial","Logistic","Regression","(","MLR",")","classifier","(","with","l2","regularization",")","in","a","semi-supervised","manner",":","..","math",":",":","(","1-\\alpha",")","Loss_","{","SRM","}","(","W_i",",","S",";","X_i",")","+","\\alpha\/\\gamma","Loss_","{","MLR","}","(","\\theta",",","bias",";","{","(","W_i^T","\\times","Z_i",",","y_i","}",")","+","R","(","\\theta",")",":","label",":","sssrm-eq","(","see","Equations","(","1",")","and","(","4",")","in","[","Turek2016","]","_",")",".","Parameters","--","--","--","--","--","n_iter",":","int",",","default",":","10","Number","of","iterations","to","run","the","algorithm",".","features",":","int",",","default",":","50","Number","of","features","to","compute",".","gamma",":","float",",","default",":","1.0","Regularization","parameter","for","the","classifier",".","alpha",":","float",",","default",":","0.5","Balance","parameter","between","the","SRM","term","and","the","MLR","term",".","rand_seed",":","int",",","default",":","0","Seed","for","initializing","the","random","number","generator",".","Attributes","--","--","--","--","--","w_",":","list","of","array",",","element","i","has","shape=","[","voxels_i",",","features","]","The","orthogonal","transforms","(","mappings",")","for","each","subject",".","s_",":","array",",","shape=","[","features",",","samples","]","The","shared","response",".","theta_",":","array",",","shape=","[","classes",",","features","]","The","MLR","class","plane","parameters",".","bias_",":","array",",","shape=","[","classes","]","The","MLR","class","biases",".","classes_",":","array","of","int",",","shape=","[","classes","]","Mapping","table","for","each","classes","to","original","class","label",".","random_state_",":","`","RandomState","`","Random","number","generator","initialized","using","rand_seed","Note","--","--","The","number","of","voxels","may","be","different","between","subjects",".","However",",","the","number","of","samples","for","the","alignment","data","must","be","the","same","across","subjects",".","The","number","of","labeled","samples","per","subject","can","be","different",".","The","Semi-Supervised","Shared","Response","Model","is","approximated","using","the","Block-Coordinate","Descent","(","BCD",")","algorithm","proposed","in","[","Turek2016","]","_",".","This","is","a","single","node","version","."]
docstr: Compute the Semi-Supervised Shared Response Model
  
  Parameters
  ----------
  
  X : list of 2D arrays, element i has shape=[voxels_i, n_align]
      Each element in the list contains the fMRI data for alignment of
      one subject. There are n_align samples for each subject.
  
  y : list of arrays of int, element i has shape=[samples_i]
      Each element in the list contains the labels for the data samples
      in Z.
  
  Z : list of 2D arrays, element i has shape=[voxels_i, samples_i]
      Each element in the list contains the fMRI data of one subject
      for training the MLR classifier.
docstr_tok: ["Compute","the","Semi-Supervised","Shared","Response","Model","Parameters","--","--","--","--","--","X",":","list","of","2D","arrays",",","element","i","has","shape=","[","voxels_i",",","n_align","]","Each","element","in","the","list","contains","the","fMRI","data","for","alignment","of","one","subject",".","There","are","n_align","samples","for","each","subject",".","y",":","list","of","arrays","of","int",",","element","i","has","shape=","[","samples_i","]","Each","element","in","the","list","contains","the","labels","for","the","data","samples","in","Z",".","Z",":","list","of","2D","arrays",",","element","i","has","shape=","[","voxels_i",",","samples_i","]","Each","element","in","the","list","contains","the","fMRI","data","of","one","subject","for","training","the","MLR","classifier","."]
code: def fit(self, X, y, Z):
      """Compute the Semi-Supervised Shared Response Model
  
      Parameters
      ----------
  
      X : list of 2D arrays, element i has shape=[voxels_i, n_align]
          Each element in the list contains the fMRI data for alignment of
          one subject. There are n_align samples for each subject.
  
      y : list of arrays of int, element i has shape=[samples_i]
          Each element in the list contains the labels for the data samples
          in Z.
  
      Z : list of 2D arrays, element i has shape=[voxels_i, samples_i]
          Each element in the list contains the fMRI data of one subject
          for training the MLR classifier.
  
      """
      logger.info("Starting SS-SRM")
  
      # Check that the alpha value is in range (0.0,1.0)
      if 0.0 >= self.alpha or self.alpha >= 1.0:
          raise ValueError(
              "Alpha parameter should be in range (0.0, 1.0)"
          )
  
      # Check that the regularizer value is positive
      if 0.0 >= self.gamma:
          raise ValueError("Gamma parameter should be positive.")
  
      # Check the number of subjects
      if len(X) <= 1 or len(y) <= 1 or len(Z) <= 1:
          raise ValueError(
              "There are not enough subjects in the input "
              "data to train the model."
          )
  
      if not (len(X) == len(y)) or not (len(X) == len(Z)):
          raise ValueError("Different number of subjects in data.")
  
      # Check for input data sizes
      if X[0].shape[1] < self.features:
          raise ValueError(
              "There are not enough samples to train the model with "
              "{0:d} features.".format(self.features)
          )
  
      # Check if all subjects have same number of TRs for alignment
      # and if alignment and classification data have the same number of
      # voxels per subject. Also check that there labels for all the classif.
      # sample
      number_trs = X[0].shape[1]
      number_subjects = len(X)
      for subject in range(number_subjects):
          assert_all_finite(X[subject])
          assert_all_finite(Z[subject])
          if X[subject].shape[1] != number_trs:
              raise ValueError(
                  "Different number of alignment samples "
                  "between subjects."
              )
          if X[subject].shape[0] != Z[subject].shape[0]:
              raise ValueError(
                  "Different number of voxels between alignment"
                  " and classification data (subject {0:d})"
                  ".".format(subject)
              )
          if Z[subject].shape[1] != y[subject].size:
              raise ValueError(
                  "Different number of samples and labels in "
                  "subject {0:d}.".format(subject)
              )
  
      # Map the classes to [0..C-1]
      new_y = self._init_classes(y)
  
      # Run SS-SRM
      self.w_, self.s_, self.theta_, self.bias_ = self._sssrm(
          X, Z, new_y
      )
  
      return self
  
imports: import logging
  import numpy
  from sklearn.base import BaseEstimator, TransformerMixin, ClassifierMixin
  from sklearn.utils import assert_all_finite
  from sklearn.utils.validation import NotFittedError
  from sklearn.utils.multiclass import unique_labels
  import theano
  import theano.tensor
  import theano.compile.sharedvalue
  from pymanopt.manifolds import Euclidean
  from pymanopt.manifolds import Product
  from pymanopt.solvers import ConjugateGradient
  from pymanopt import Problem
  from pymanopt.manifolds import Stiefel
  import pymanopt
  import gc
  from brainiak.utils import utils
  from brainiak.funcalign import srm
label_desc: Use image node_id 2 for calling the SSSRM obj's underlying member method code with example usage: obj.fit(X, y, Z) and returns: self