code: def testRandomDenseFlipout(self):
      batch_size, in_size, out_size = 2, 3, 4
      with self.cached_session() as sess:
          seed = Counter()
          inputs = tf.random.uniform([batch_size, in_size], seed=seed())
  
          kernel_posterior = MockDistribution(
              loc=tf.random.uniform([in_size, out_size], seed=seed()),
              scale=tf.random.uniform([in_size, out_size], seed=seed()),
              result_log_prob=tf.random.uniform(
                  [in_size, out_size], seed=seed()
              ),
              result_sample=tf.random.uniform(
                  [in_size, out_size], seed=seed()
              ),
          )
          bias_posterior = MockDistribution(
              loc=tf.random.uniform([out_size], seed=seed()),
              scale=tf.random.uniform([out_size], seed=seed()),
              result_log_prob=tf.random.uniform(
                  [out_size], seed=seed()
              ),
              result_sample=tf.random.uniform([out_size], seed=seed()),
          )
          layer_one = dense_variational.DenseFlipout(
              units=out_size,
              kernel_posterior_fn=lambda *args: kernel_posterior,
              kernel_posterior_tensor_fn=lambda d: d.sample(seed=42),
              kernel_divergence_fn=None,
              bias_posterior_fn=lambda *args: bias_posterior,
              bias_posterior_tensor_fn=lambda d: d.sample(seed=43),
              bias_divergence_fn=None,
              seed=44,
          )
          layer_two = dense_variational.DenseFlipout(
              units=out_size,
              kernel_posterior_fn=lambda *args: kernel_posterior,
              kernel_posterior_tensor_fn=lambda d: d.sample(seed=42),
              kernel_divergence_fn=None,
              bias_posterior_fn=lambda *args: bias_posterior,
              bias_posterior_tensor_fn=lambda d: d.sample(seed=43),
              bias_divergence_fn=None,
              seed=45,
          )
  
          outputs_one = layer_one(inputs)
          outputs_two = layer_two(inputs)
  
          outputs_one_, outputs_two_ = sess.run(
              [outputs_one, outputs_two]
          )
  
          self.assertLess(
              np.sum(np.isclose(outputs_one_, outputs_two_)), out_size
          )
  
imports: import numpy
  import tensorflow.compat.v2
  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
  from tensorflow_probability.python.layers import util
  from tensorflow_probability.python.random import random_ops
  from tensorflow_probability.python.util import seed_stream
label_desc: Use image node_id 17 for calling the DenseVariational obj's underlying member method code with example usage: obj.testRandomDenseFlipout() without return types