class_docstr: State space model for a semi-local linear trend.
  
  A state space model (SSM) posits a set of latent (unobserved) variables that
  evolve over time with dynamics specified by a probabilistic transition model
  `p(z[t+1] | z[t])`. At each timestep, we observe a value sampled from an
  observation model conditioned on the current state, `p(x[t] | z[t])`. The
  special case where both the transition and observation models are Gaussians
  with mean specified as a linear function of the inputs, is known as a linear
  Gaussian state space model and supports tractable exact probabilistic
  calculations; see `tfp.distributions.LinearGaussianStateSpaceModel` for
  details.
  
  The semi-local linear trend model is a special case of a linear Gaussian
  SSM, in which the latent state posits a `level` and `slope`. The `level`
  evolves via a Gaussian random walk centered at the current `slope`, while
  the `slope` follows a first-order autoregressive (AR1) process with
  mean `slope_mean`:
  
  ```python
  level[t] = level[t-1] + slope[t-1] + Normal(0., level_scale)
  slope[t] = (slope_mean +
              autoregressive_coef * (slope[t-1] - slope_mean) +
              Normal(0., slope_scale))
  ```
  
  The latent state is the two-dimensional tuple `[level, slope]`. The
  `level` is observed at each timestep.
  
  The parameters `level_scale`, `slope_mean`, `slope_scale`,
  `autoregressive_coef`, and `observation_noise_scale` are each (a batch of)
  scalars. The batch shape of this `Distribution` is the broadcast batch shape
  of these parameters and of the `initial_state_prior`.
  
  #### Mathematical Details
  
  The semi-local linear trend model implements a
  `tfp.distributions.LinearGaussianStateSpaceModel` with `latent_size = 2`
  and `observation_size = 1`, following the transition model:
  
  ```
  transition_matrix = [[1., 1.]
                       [0., autoregressive_coef]]
  transition_noise ~ N(loc=slope_mean - autoregressive_coef * slope_mean,
                       scale=diag([level_scale, slope_scale]))
  ```
  
  which implements the evolution of `[level, slope]` described above, and
  the observation model:
  
  ```
  observation_matrix = [[1., 0.]]
  observation_noise ~ N(loc=0, scale=observation_noise_scale)
  ```
  
  which picks out the first latent component, i.e., the `level`, as the
  observation at each timestep.
  
  #### Examples
  
  A simple model definition:
  
  ```python
  semilocal_trend_model = SemiLocalLinearTrendStateSpaceModel(
      num_timesteps=50,
      level_scale=0.5,
      slope_mean=0.2,
      slope_scale=0.5,
      autoregressive_coef=0.9,
      initial_state_prior=tfd.MultivariateNormalDiag(scale_diag=[1., 1.]))
  
  y = semilocal_trend_model.sample() # y has shape [50, 1]
  lp = semilocal_trend_model.log_prob(y) # log_prob is scalar
  ```
  
  Passing additional parameter dimensions constructs a batch of models. The
  overall batch shape is the broadcast batch shape of the parameters:
  
  ```python
  semilocal_trend_model = SemiLocalLinearTrendStateSpaceModel(
      num_timesteps=50,
      level_scale=tf.ones([10]),
      slope_mean=0.2,
      slope_scale=0.5,
      autoregressive_coef=0.9,
      initial_state_prior=tfd.MultivariateNormalDiag(
        scale_diag=tf.ones([10, 10, 2])))
  
  y = semilocal_trend_model.sample(5)    # y has shape [5, 10, 10, 50, 1]
  lp = semilocal_trend_model.log_prob(y) # lp has shape [5, 10, 10]
  ```
class_docstr_tok: ["State","space","model","for","a","semi-local","linear","trend",".","A","state","space","model","(","SSM",")","posits","a","set","of","latent","(","unobserved",")","variables","that","evolve","over","time","with","dynamics","specified","by","a","probabilistic","transition","model","`","p","(","z","[","t+1","]","|","z","[","t","]",")","`",".","At","each","timestep",",","we","observe","a","value","sampled","from","an","observation","model","conditioned","on","the","current","state",",","`","p","(","x","[","t","]","|","z","[","t","]",")","`",".","The","special","case","where","both","the","transition","and","observation","models","are","Gaussians","with","mean","specified","as","a","linear","function","of","the","inputs",",","is","known","as","a","linear","Gaussian","state","space","model","and","supports","tractable","exact","probabilistic","calculations",";","see","`","tfp.distributions.LinearGaussianStateSpaceModel","`","for","details",".","The","semi-local","linear","trend","model","is","a","special","case","of","a","linear","Gaussian","SSM",",","in","which","the","latent","state","posits","a","`","level","`","and","`","slope","`",".","The","`","level","`","evolves","via","a","Gaussian","random","walk","centered","at","the","current","`","slope","`",",","while","the","`","slope","`","follows","a","first-order","autoregressive","(","AR1",")","process","with","mean","`","slope_mean","`",":","``","`","python","level","[","t","]","=","level","[","t-1","]","+","slope","[","t-1","]","+","Normal","(","0.",",","level_scale",")","slope","[","t","]","=","(","slope_mean","+","autoregressive_coef","*","(","slope","[","t-1","]","-","slope_mean",")","+","Normal","(","0.",",","slope_scale",")",")","``","`","The","latent","state","is","the","two-dimensional","tuple","`","[","level",",","slope","]","`",".","The","`","level","`","is","observed","at","each","timestep",".","The","parameters","`","level_scale","`",",","`","slope_mean","`",",","`","slope_scale","`",",","`","autoregressive_coef","`",",","and","`","observation_noise_scale","`","are","each","(","a","batch","of",")","scalars",".","The","batch","shape","of","this","`","Distribution","`","is","the","broadcast","batch","shape","of","these","parameters","and","of","the","`","initial_state_prior","`",".","#","#","#","#","Mathematical","Details","The","semi-local","linear","trend","model","implements","a","`","tfp.distributions.LinearGaussianStateSpaceModel","`","with","`","latent_size","=","2","`","and","`","observation_size","=","1","`",",","following","the","transition","model",":","``","`","transition_matrix","=","[","[","1.",",","1",".","]","[","0.",",","autoregressive_coef","]","]","transition_noise","~","N","(","loc=slope_mean","-","autoregressive_coef","*","slope_mean",",","scale=diag","(","[","level_scale",",","slope_scale","]",")",")","``","`","which","implements","the","evolution","of","`","[","level",",","slope","]","`","described","above",",","and","the","observation","model",":","``","`","observation_matrix","=","[","[","1.",",","0",".","]","]","observation_noise","~","N","(","loc=0",",","scale=observation_noise_scale",")","``","`","which","picks","out","the","first","latent","component",",","i.e.",",","the","`","level","`",",","as","the","observation","at","each","timestep",".","#","#","#","#","Examples","A","simple","model","definition",":","``","`","python","semilocal_trend_model","=","SemiLocalLinearTrendStateSpaceModel","(","num_timesteps=50",",","level_scale=0.5",",","slope_mean=0.2",",","slope_scale=0.5",",","autoregressive_coef=0.9",",","initial_state_prior=tfd.MultivariateNormalDiag","(","scale_diag=","[","1.",",","1",".","]",")",")","y","=","semilocal_trend_model.sample","(",")","#","y","has","shape","[","50",",","1","]","lp","=","semilocal_trend_model.log_prob","(","y",")","#","log_prob","is","scalar","``","`","Passing","additional","parameter","dimensions","constructs","a","batch","of","models",".","The","overall","batch","shape","is","the","broadcast","batch","shape","of","the","parameters",":","``","`","python","semilocal_trend_model","=","SemiLocalLinearTrendStateSpaceModel","(","num_timesteps=50",",","level_scale=tf.ones","(","[","10","]",")",",","slope_mean=0.2",",","slope_scale=0.5",",","autoregressive_coef=0.9",",","initial_state_prior=tfd.MultivariateNormalDiag","(","scale_diag=tf.ones","(","[","10",",","10",",","2","]",")",")",")","y","=","semilocal_trend_model.sample","(","5",")","#","y","has","shape","[","5",",","10",",","10",",","50",",","1","]","lp","=","semilocal_trend_model.log_prob","(","y",")","#","lp","has","shape","[","5",",","10",",","10","]","``","`"]
code: def slope_mean(self):
      return self._slope_mean
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import sigmoid
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.bijectors import tanh
  from tensorflow_probability.python.distributions import linear_gaussian_ssm
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.sts.internal import util
  from tensorflow_probability.python.sts.structural_time_series import Parameter
  from tensorflow_probability.python.sts.structural_time_series import StructuralTimeSeries
label_desc: Use image node_id 3 for calling the SemiLocalLinearTrendStateSpaceModel obj's underlying member method code with example usage: obj.slope_mean() and returns: self