docstr: ...Test that computed losses are consistent with approximated
  theoretical values
docstr_tok: ["...","Test","that","computed","losses","are","consistent","with","approximated","theoretical","values"]
code: def test_model_hawkes_sum_exp_kernel_varying_baseline_least_sq_loss(
      self,
  ):
      """...Test that computed losses are consistent with approximated
      theoretical values
      """
      timestamps = self.timestamps_list[self.realization]
      end_time = self.model.end_times[self.realization]
  
      n_baselines = 3
      period_length = 1.0
      baselines = np.random.rand(self.dim, n_baselines)
  
      def baseline_function(i):
          def baseline_value(t):
              first_t = t - period_length * int(t / period_length)
              interval = min(
                  int(first_t / period_length * n_baselines),
                  n_baselines - 1,
              )
              return baselines[i, interval]
  
          return baseline_value
  
      baseline_functions = [
          baseline_function(i) for i in range(self.dim)
      ]
  
      intensities = hawkes_sumexp_kernel_varying_intensities(
          baseline_functions, self.decays, self.adjacency, timestamps
      )
  
      integral_approx = hawkes_least_square_error(
          intensities, timestamps, end_time
      )
      integral_approx /= self.model.n_jumps
  
      model = ModelHawkesSumExpKernLeastSq(
          decays=self.decays,
          n_baselines=n_baselines,
          period_length=period_length,
      )
      model.fit(self.timestamps_list[self.realization])
  
      coeffs = np.hstack((baselines.ravel(), self.adjacency.ravel()))
      self.assertAlmostEqual(
          integral_approx, model.loss(coeffs), places=2
      )
  
imports: import pickle
  import unittest
  import numpy
  from numpy.linalg import norm
  from scipy.optimize import check_grad, fmin_bfgs
  from tick.base.inference import InferenceTest
  from tick.hawkes.model import ModelHawkesSumExpKernLeastSq
  from tick.hawkes.model.tests.model_hawkes_test_utils import hawkes_sumexp_kernel_intensities, hawkes_sumexp_kernel_varying_intensities, hawkes_least_square_error
label_desc: Use image node_id 10 for calling the Test obj's underlying member method code with example usage: obj.test_model_hawkes_sum_exp_kernel_varying_baseline_least_sq_loss() and returns: baseline_value, baselines