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: Derivation of obs which is used in derivative function `df_obs` while optimizing.
  
  Parameters
  ----------
  word : int
      The word's ID.
  word_counts : list of int
      Total word counts for each time slice.
  totals : list of int of length `len(self.time_slice)`
      The totals for each time slice.
  mean_deriv_mtx : list of float
      Mean derivative for each time slice.
  deriv : list of float
      Mean derivative for each time slice.
  
  Returns
  -------
  list of float
      Mean derivative for each time slice.
docstr_tok: ["Derivation","of","obs","which","is","used","in","derivative","function","`","df_obs","`","while","optimizing",".","Parameters","--","--","--","--","--","word",":","int","The","word","'s","ID",".","word_counts",":","list","of","int","Total","word","counts","for","each","time","slice",".","totals",":","list","of","int","of","length","`","len","(","self.time_slice",")","`","The","totals","for","each","time","slice",".","mean_deriv_mtx",":","list","of","float","Mean","derivative","for","each","time","slice",".","deriv",":","list","of","float","Mean","derivative","for","each","time","slice",".","Returns","--","--","--","-","list","of","float","Mean","derivative","for","each","time","slice","."]
code: def compute_obs_deriv(
      self, word, word_counts, totals, mean_deriv_mtx, deriv
  ):
      """Derivation of obs which is used in derivative function `df_obs` while optimizing.
  
      Parameters
      ----------
      word : int
          The word's ID.
      word_counts : list of int
          Total word counts for each time slice.
      totals : list of int of length `len(self.time_slice)`
          The totals for each time slice.
      mean_deriv_mtx : list of float
          Mean derivative for each time slice.
      deriv : list of float
          Mean derivative for each time slice.
  
      Returns
      -------
      list of float
          Mean derivative for each time slice.
  
      """
  
      # flag
      init_mult = 1000
  
      T = self.num_time_slices
  
      mean = self.mean[word]
      variance = self.variance[word]
  
      # only used for DIM mode
      # w_phi_l = self.w_phi_l[word]
      # m_update_coeff = self.m_update_coeff[word]
  
      # temp_vector holds temporary zeta values
      self.temp_vect = np.zeros(T)
  
      for u in range(T):
          self.temp_vect[u] = np.exp(mean[u + 1] + variance[u + 1] / 2)
  
      for t in range(T):
          mean_deriv = mean_deriv_mtx[t]
          term1 = 0
          term2 = 0
          term3 = 0
          term4 = 0
  
          for u in range(1, T + 1):
              mean_u = mean[u]
              mean_u_prev = mean[u - 1]
              dmean_u = mean_deriv[u]
              dmean_u_prev = mean_deriv[u - 1]
  
              term1 += (mean_u - mean_u_prev) * (dmean_u - dmean_u_prev)
              term2 += (
                  word_counts[u - 1]
                  - (
                      totals[u - 1]
                      * self.temp_vect[u - 1]
                      / self.zeta[u - 1]
                  )
              ) * dmean_u
  
              model = "DTM"
              if model == "DIM":
                  # do some stuff
                  pass
  
          if self.chain_variance:
              term1 = -(term1 / self.chain_variance)
              term1 = term1 - (mean[0] * mean_deriv[0]) / (
                  init_mult * self.chain_variance
              )
          else:
              term1 = 0.0
  
          deriv[t] = term1 + term2 + term3 + term4
  
      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 11 for calling the sslm obj's underlying member method code with example usage: obj.compute_obs_deriv(word, word_counts, totals, mean_deriv_mtx, deriv) and returns: deriv