code: def _maybe_expand_trailing_dim(observed_time_series_tensor):
      """Ensures `observed_time_series_tensor` has a trailing dimension of size 1.
  
      The `tfd.LinearGaussianStateSpaceModel` Distribution has event shape of
      `[num_timesteps, observation_size]`, but canonical BSTS models
      are univariate, so their observation_size is always `1`. The extra trailing
      dimension gets annoying, so this method allows arguments with or without the
      extra dimension. There is no ambiguity except in the trivial special case
      where  `num_timesteps = 1`; this can be avoided by specifying any unit-length
      series in the explicit `[num_timesteps, 1]` style.
  
      Most users should not call this method directly, and instead call
      `canonicalize_observed_time_series_with_mask`, which handles converting
      to `Tensor` and specifying an optional missingness mask.
  
      Args:
        observed_time_series_tensor: `Tensor` of shape
          `batch_shape + [num_timesteps, 1]` or `batch_shape + [num_timesteps]`,
          where `num_timesteps > 1`.
  
      Returns:
        expanded_time_series: `Tensor` of shape `batch_shape + [num_timesteps, 1]`.
      """
  
      with tf.name_scope("maybe_expand_trailing_dim"):
          if (
              tensorshape_util.rank(observed_time_series_tensor.shape)
              is not None
              and tf.compat.dimension_value(
                  observed_time_series_tensor.shape[-1]
              )
              is not None
          ):
              expanded_time_series = (
                  observed_time_series_tensor
                  if observed_time_series_tensor.shape[-1] == 1
                  else observed_time_series_tensor[..., tf.newaxis]
              )
          else:
              expanded_time_series = tf.cond(
                  pred=tf.equal(
                      tf.shape(observed_time_series_tensor)[-1], 1
                  ),
                  true_fn=lambda: observed_time_series_tensor,
                  false_fn=lambda: observed_time_series_tensor[
                      ..., tf.newaxis
                  ],
              )
          return expanded_time_series
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_linear_operator
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.sts.internal import missing_values_util
label_desc: Use image node_id 7 for calling a global function with example usage: _maybe_expand_trailing_dim(observed_time_series_tensor) and returns: expanded_time_series