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 objective function of the Semi-Supervised SRM
  
  See :eq:`sssrm-eq`.
  
  Parameters
  ----------
  
  data_align : 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.
  
  data_sup : 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
      the classification task.
  
  labels : list of arrays of int, element i has shape=[samples_i]
      Each element in the list contains the labels for the data samples
      in data_sup.
  
  w : list of array, element i has shape=[voxels_i, features]
      The orthogonal transforms (mappings) :math:`W_i` 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.
  
  
  Returns
  -------
  
  f_val : float
      The SS-SRM objective function evaluated based on the parameters to
      this function.
docstr_tok: ["Compute","the","objective","function","of","the","Semi-Supervised","SRM","See",":","eq",":","`","sssrm-eq","`",".","Parameters","--","--","--","--","--","data_align",":","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",".","data_sup",":","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","the","classification","task",".","labels",":","list","of","arrays","of","int",",","element","i","has","shape=","[","samples_i","]","Each","element","in","the","list","contains","the","labels","for","the","data","samples","in","data_sup",".","w",":","list","of","array",",","element","i","has","shape=","[","voxels_i",",","features","]","The","orthogonal","transforms","(","mappings",")",":","math",":","`","W_i","`","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",".","Returns","--","--","--","-","f_val",":","float","The","SS-SRM","objective","function","evaluated","based","on","the","parameters","to","this","function","."]
code: def _objective_function(
      self, data_align, data_sup, labels, w, s, theta, bias
  ):
      """Compute the objective function of the Semi-Supervised SRM
  
      See :eq:`sssrm-eq`.
  
      Parameters
      ----------
  
      data_align : 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.
  
      data_sup : 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
          the classification task.
  
      labels : list of arrays of int, element i has shape=[samples_i]
          Each element in the list contains the labels for the data samples
          in data_sup.
  
      w : list of array, element i has shape=[voxels_i, features]
          The orthogonal transforms (mappings) :math:`W_i` 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.
  
  
      Returns
      -------
  
      f_val : float
          The SS-SRM objective function evaluated based on the parameters to
          this function.
      """
      subjects = len(data_align)
  
      # Compute the SRM  loss
      f_val = 0.0
      for subject in range(subjects):
          samples = data_align[subject].shape[1]
          f_val += (
              (1 - self.alpha)
              * (0.5 / samples)
              * np.linalg.norm(
                  data_align[subject] - w[subject].dot(s), "fro"
              )
              ** 2
          )
  
      # Compute the MLR loss
      f_val += self._loss_lr(data_sup, labels, w, theta, bias)
  
      return f_val
  
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 10 for calling the SSSRM obj's underlying member method code with example usage: obj._objective_function(data_align, data_sup, labels, w, s, theta, bias) and returns: f_val