class_docstr: Base class of Hawkes models
  
  Notes
  -----
  This class should be not used by end-users, it is intended for
  development only.
class_docstr_tok: ["Base","class","of","Hawkes","models","Notes","--","--","-","This","class","should","be","not","used","by","end-users",",","it","is","intended","for","development","only","."]
docstr: Return model's hessian
  
  Parameters
  ----------
  x : `np.ndarray`, shape=(n_coeffs,)
      Value at which the hessian is computed
  
  Notes
  -----
  For `ModelHawkesExpKernLeastSq` the value of the hessian
  does not depend on the value at which it is computed.
docstr_tok: ["Return","model","'s","hessian","Parameters","--","--","--","--","--","x",":","`","np.ndarray","`",",","shape=","(","n_coeffs",",",")","Value","at","which","the","hessian","is","computed","Notes","--","--","-","For","`","ModelHawkesExpKernLeastSq","`","the","value","of","the","hessian","does","not","depend","on","the","value","at","which","it","is","computed","."]
code: def hessian(self, x):
      """Return model's hessian
  
      Parameters
      ----------
      x : `np.ndarray`, shape=(n_coeffs,)
          Value at which the hessian is computed
  
      Notes
      -----
      For `ModelHawkesExpKernLeastSq` the value of the hessian
      does not depend on the value at which it is computed.
      """
      if not hasattr(self._model, "hessian"):
          raise NotImplementedError(
              "hessian is not implemented yet for " "this model"
          )
  
      if not self._fitted:
          raise ValueError("call ``fit`` before using ``hessian``")
  
      # What kind of integers does scipy use fr sparse indices?
      sparse_dtype = sputils.get_index_dtype()
  
      n_baselines = self.n_nodes
      # number of alphas per dimension
      if isinstance(
          self._model,
          (ModelHawkesSumExpKernLeastSq, ModelHawkesSumExpKernLogLik),
      ):
          n_alphas_i = self.n_nodes * len(self.decays)
      else:
          n_alphas_i = self.n_nodes
  
      dim = self.n_nodes
      row_indices_size = n_baselines + dim * n_alphas_i + 1
      data_size = (n_baselines + dim * n_alphas_i) * (1 + n_alphas_i)
  
      # looks like [0  3  6  9 12 15 18] in dimension 2
      row_indices = np.arange(row_indices_size, dtype=sparse_dtype) * (
          1 + n_alphas_i
      )
  
      # looks like [0 2 3 1 4 5 0 2 3 0 2 3 1 4 5 1 4 5] in dimension 2
      # We first create the recurrent pattern for each dim
      block_dim = {}
      for d in range(dim):
          mu_array = np.array(d)
          alpha_array = (
              n_baselines + d * n_alphas_i + np.arange(n_alphas_i)
          )
          block_dim[d] = np.hstack((mu_array, alpha_array))
  
      # and then fill the indices array
      indices = np.zeros(data_size, dtype=sparse_dtype)
      for d in range(dim):
          indices[
              d * (n_alphas_i + 1) : (d + 1) * (n_alphas_i + 1)
          ] = block_dim[d]
          alpha_shift = n_baselines * (n_alphas_i + 1)
          alpha_d_start = alpha_shift + d * n_alphas_i * (
              n_alphas_i + 1
          )
          alpha_d_end = alpha_shift + (d + 1) * n_alphas_i * (
              n_alphas_i + 1
          )
          indices[alpha_d_start:alpha_d_end] = np.tile(
              block_dim[d], (n_alphas_i,)
          )
  
      data = np.zeros(data_size, dtype=float)
  
      # In these two models, hessian does not depend on x
      if isinstance(
          self._model,
          (ModelHawkesSumExpKernLeastSq, ModelHawkesExpKernLeastSq),
      ):
          self._model.hessian(data)
      else:
          self._model.hessian(x, data)
  
      hessian = csr_matrix((data, indices, row_indices))
      return hessian
  
file_path: tick/tick/hawkes/model/base/model_hawkes.py
imports: import numpy
  from scipy.sparse import sputils, csr_matrix
  from tick.base_model import N_CALLS_LOSS, PASS_OVER_DATA
  from tick.base_model.model_first_order import ModelFirstOrder
  from tick.hawkes.model.build.hawkes_model import ModelHawkesSumExpKernLeastSq, ModelHawkesExpKernLeastSq, ModelHawkesSumExpKernLogLik
label_desc: Use image node_id 8 for calling the ModelHawkes obj's underlying member method code with example usage: obj.hessian(x) and returns: hessian