code: def build_seasonal_transition_noise(
      drift_scale, num_seasons, is_last_day_of_season
  ):
      """Build the transition noise model for a SeasonalStateSpaceModel."""
  
      # If the current season has just ended, increase the variance of its effect
      # following drift_scale. (the just-ended seasonal effect will always be the
      # bottom element of the vector). Otherwise, do nothing.
      drift_scale_diag = tf.stack(
          [tf.zeros_like(drift_scale)] * (num_seasons - 1)
          + [drift_scale],
          axis=-1,
      )
  
      def seasonal_transition_noise(t):
          noise_scale_diag = dist_util.pick_scalar_condition(
              is_last_day_of_season(t),
              drift_scale_diag,
              tf.zeros_like(drift_scale_diag),
          )
          return mvn_diag.MultivariateNormalDiag(
              loc=tf.zeros(num_seasons, dtype=drift_scale.dtype),
              scale_diag=noise_scale_diag,
          )
  
      return seasonal_transition_noise
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.bijectors import square
  from tensorflow_probability.python.distributions import inverse_gamma
  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 mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import transformed_distribution
  from tensorflow_probability.python.experimental.sts_gibbs import sample_parameters
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import docstring_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  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 4 for calling a global function with example usage: build_seasonal_transition_noise(drift_scale, num_seasons, is_last_day_of_season) and returns: seasonal_transition_noise, mvn_diag