code: def _testKLPenaltyBoth(self, layer_class):
      with self.cached_session():
          layer = layer_class(
              units=2,
              bias_posterior_fn=util.default_mean_field_normal_fn(),
              bias_prior_fn=util.default_multivariate_normal_fn,
          )
          inputs = tf.random.uniform([2, 3], seed=1)
  
          # No keys.
          self.assertEqual(len(layer.losses), 0)
  
          _ = layer(inputs)
  
          # Yes keys.
          self.assertEqual(len(layer.losses), 2)
          self.assertEqual(layer.losses[0].shape, ())
          self.assertEqual(layer.losses[1].shape, ())
  
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 3 for calling the DenseVariational obj's underlying member method code with example usage: obj._testKLPenaltyBoth(layer_class) without return types