code: def test_basic_variational_fitting(self):
      batch_shape = [2, 3]
      num_timesteps = 5
      num_inits = 10
      observed_time_series = self._build_tensor(
          np.random.randn(*(batch_shape + [num_timesteps]))
      )
  
      model = self._build_model(observed_time_series)
  
      variational_posterior = (
          fitting.build_factored_surrogate_posterior(
              model, batch_shape=num_inits
          )
      )
      loss_curve = optimization.fit_surrogate_posterior(
          model.joint_distribution(observed_time_series).log_prob,
          surrogate_posterior=variational_posterior,
          sample_size=3,
          num_steps=10,
          optimizer=tf1.train.AdamOptimizer(learning_rate=0.1),
      )
      self.evaluate(tf1.global_variables_initializer())
      with tf.control_dependencies([loss_curve]):
          posterior_samples = variational_posterior.sample(10)
      loss_curve_, _ = self.evaluate((loss_curve, posterior_samples))
      self.assertLess(np.mean(loss_curve_[-1]), np.mean(loss_curve_[0]))
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.sts import fitting
  from tensorflow_probability.python.sts.components import local_linear_trend
  from tensorflow_probability.python.sts.components import seasonal
  from tensorflow_probability.python.sts.components import sum
  from tensorflow_probability.python.sts.internal import missing_values_util
  from tensorflow_probability.python.vi import csiszar_divergence
  from tensorflow_probability.python.vi import optimization
label_desc: Use image node_id 2 for calling the _VariationalInferenceTests obj's underlying member method code with example usage: obj.test_basic_variational_fitting() without return types