code: def test_end_to_end(self):
      # Get dataset.
      y, x, x_tst = create_dataset()
  
      layer = dense_variational_v2.DenseVariational(
          1, posterior_mean_field, prior_trainable
      )
  
      model = tf_keras.Sequential(
          [
              layer,
              distribution_layer.DistributionLambda(
                  lambda t: normal.Normal(loc=t, scale=1)
              ),
          ]
      )
  
      if tf.__internal__.tf2.enabled() and tf.executing_eagerly():
          optimizer = tf_keras.optimizers.Adam(learning_rate=0.05)
      else:
          optimizer = tf_keras.optimizers.legacy.Adam(
              learning_rate=0.05
          )
      # Do inference.
      model.compile(optimizer=optimizer, loss=negloglik)
      model.fit(x, y, epochs=2, verbose=False)
  
      self.assertLen(model.layers, 2)
      self.assertLen(model.layers[0].variables, 2)
      self.assertEmpty(model.layers[1].variables)
  
      posterior, prior = model.layers[0].variables
      self.assertNotEqual(prior.name, posterior.name)
      self.assertContainsSubsequence(posterior.name, "/posterior/")
      self.assertContainsSubsequence(prior.name, "/prior/")
  
      # Check the output_shape.
      expected_output_shape = layer.compute_output_shape(
          (None, x.shape[-1])
      ).as_list()
      self.assertAllEqual(expected_output_shape, (None, 1))
  
      # Profit.
      yhat = model(x_tst)
      self.assertIsInstance(yhat, distribution.Distribution)
  
file_path: probability/tensorflow_probability/python/layers/dense_variational_v2_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.layers import dense_variational_v2
  from tensorflow_probability.python.layers import distribution_layer
  from tensorflow_probability.python.layers import variable_input
label_desc: Use image node_id 1 for calling the DenseVariationalLayerTest obj's underlying member method code with example usage: obj.test_end_to_end() without return types