class_docstr: Encapsulate the inner State Space Language Model for DTM.
  
  Some important attributes of this class:
  
      * `obs` is a matrix containing the document to topic ratios.
      * `e_log_prob` is a matrix containing the topic to word ratios.
      * `mean` contains the mean values to be used for inference for each word for a time slice.
      * `variance` contains the variance values to be used for inference of word in a time slice.
      * `fwd_mean` and`fwd_variance` are the forward posterior values for the mean and the variance.
      * `zeta` is an extra variational parameter with a value for each time slice.
class_docstr_tok: ["Encapsulate","the","inner","State","Space","Language","Model","for","DTM",".","Some","important","attributes","of","this","class",":","*","`","obs","`","is","a","matrix","containing","the","document","to","topic","ratios",".","*","`","e_log_prob","`","is","a","matrix","containing","the","topic","to","word","ratios",".","*","`","mean","`","contains","the","mean","values","to","be","used","for","inference","for","each","word","for","a","time","slice",".","*","`","variance","`","contains","the","variance","values","to","be","used","for","inference","of","word","in","a","time","slice",".","*","`","fwd_mean","`","and","`","fwd_variance","`","are","the","forward","posterior","values","for","the","mean","and","the","variance",".","*","`","zeta","`","is","an","extra","variational","parameter","with","a","value","for","each","time","slice","."]
docstr: Helper functions for optimizing a function.
  
  Compute the derivative of:
  
  .. :math::
  
      E[eta_{t,w}]/d obs_{s,w} for t = 1:T.
  
  Parameters
  ----------
  word : int
      The word's ID.
  time : int
      The time slice.
  deriv : list of float
      Derivative for each time slice.
  
  Returns
  -------
  list of float
      Mean derivative for each time slice.
docstr_tok: ["Helper","functions","for","optimizing","a","function",".","Compute","the","derivative","of",":","..",":","math",":",":","E","[","\beta_","{","t",",","w","}","]","\/d","obs_","{","s",",","w","}","for","t","=","1",":","T.","Parameters","--","--","--","--","--","word",":","int","The","word","'s","ID",".","time",":","int","The","time","slice",".","deriv",":","list","of","float","Derivative","for","each","time","slice",".","Returns","--","--","--","-","list","of","float","Mean","derivative","for","each","time","slice","."]
code: def compute_mean_deriv(self, word, time, deriv):
      """Helper functions for optimizing a function.
  
      Compute the derivative of:
  
      .. :math::
  
          E[\beta_{t,w}]/d obs_{s,w} for t = 1:T.
  
      Parameters
      ----------
      word : int
          The word's ID.
      time : int
          The time slice.
      deriv : list of float
          Derivative for each time slice.
  
      Returns
      -------
      list of float
          Mean derivative for each time slice.
  
      """
  
      T = self.num_time_slices
      fwd_variance = self.variance[word]
  
      deriv[0] = 0
  
      # forward pass
      for t in range(1, T + 1):
          if self.obs_variance > 0.0:
              w = self.obs_variance / (
                  fwd_variance[t - 1]
                  + self.chain_variance
                  + self.obs_variance
              )
          else:
              w = 0.0
          val = w * deriv[t - 1]
          if time == t - 1:
              val += 1 - w
          deriv[t] = val
  
      for t in range(T - 1, -1, -1):
          if self.chain_variance == 0.0:
              w = 0.0
          else:
              w = self.chain_variance / (
                  fwd_variance[t] + self.chain_variance
              )
          deriv[t] = w * deriv[t] + (1 - w) * deriv[t + 1]
  
      return deriv
  
imports: import logging
  import numpy
  from scipy.special import digamma, gammaln
  from scipy import optimize
  from gensim import utils, matutils
  from gensim.models import ldamodel
label_desc: Use image node_id 10 for calling the sslm obj's underlying member method code with example usage: obj.compute_mean_deriv(word, time, deriv) and returns: deriv