code: def test_sum_of_local_linear_trends(self):
      # We know analytically that the sum of two local linear trends is
      # another local linear trend, with means and variances scaled
      # accordingly, so the additive model should match this behavior.
  
      level_scale = 0.5
      slope_scale = 1.1
      initial_level = 3.0
      initial_slope = -2.0
      observation_noise_scale = 0.0
      num_timesteps = 5
      y = self._build_placeholder([1.0, 2.5, 4.3, 6.1, 7.8])
  
      # Combine two local linear trend models, one a full model, the other
      # with just a moving mean (zero slope).
      local_ssm = LocalLinearTrendStateSpaceModel(
          num_timesteps=num_timesteps,
          level_scale=level_scale,
          slope_scale=slope_scale,
          initial_state_prior=mvn_diag.MultivariateNormalDiag(
              loc=self._build_placeholder(
                  [initial_level, initial_slope]
              ),
              scale_diag=self._build_placeholder([1.0, 1.0]),
          ),
      )
  
      second_level_scale = 0.3
      second_initial_level = 1.1
      moving_level_ssm = LocalLinearTrendStateSpaceModel(
          num_timesteps=num_timesteps,
          level_scale=second_level_scale,
          slope_scale=0.0,
          initial_state_prior=mvn_diag.MultivariateNormalDiag(
              loc=self._build_placeholder([second_initial_level, 0.0]),
              scale_diag=self._build_placeholder([1.0, 0.0]),
          ),
      )
  
      additive_ssm = AdditiveStateSpaceModel(
          [local_ssm, moving_level_ssm],
          observation_noise_scale=observation_noise_scale,
      )
  
      # Build the analytical sum of the two processes.
      target_ssm = LocalLinearTrendStateSpaceModel(
          num_timesteps=num_timesteps,
          level_scale=np.float32(
              np.sqrt(level_scale**2 + second_level_scale**2)
          ),
          slope_scale=np.float32(slope_scale),
          observation_noise_scale=observation_noise_scale,
          initial_state_prior=mvn_diag.MultivariateNormalDiag(
              loc=self._build_placeholder(
                  [
                      initial_level + second_initial_level,
                      initial_slope + 0.0,
                  ]
              ),
              scale_diag=self._build_placeholder(np.sqrt([2.0, 1.0])),
          ),
      )
  
      # Test that both models behave equivalently.
      additive_mean = additive_ssm.mean()
      target_mean = target_ssm.mean()
      self.assertAllClose(
          self.evaluate(additive_mean), self.evaluate(target_mean)
      )
  
      additive_variance = additive_ssm.variance()
      target_variance = target_ssm.variance()
      self.assertAllClose(
          self.evaluate(additive_variance),
          self.evaluate(target_variance),
      )
  
      additive_lp = additive_ssm.log_prob(y[:, np.newaxis])
      target_lp = target_ssm.log_prob(y[:, np.newaxis])
      self.assertAllClose(
          self.evaluate(additive_lp), self.evaluate(target_lp)
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import linear_gaussian_ssm
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.sts.components.local_linear_trend import LocalLinearTrendStateSpaceModel
  from tensorflow_probability.python.sts.components.sum import AdditiveStateSpaceModel
label_desc: Use image node_id 3 for calling the _AdditiveStateSpaceModelTest obj's underlying member method code with example usage: obj.test_sum_of_local_linear_trends() without return types