class_docstr: Abstract densely-connected class (private, used as implementation base).
  
  This layer implements the Bayesian variational inference analogue to
  a dense layer by assuming the `kernel` and/or the `bias` are drawn
  from distributions. By default, the layer implements a stochastic
  forward pass via sampling from the kernel and bias posteriors,
  
  ```none
  kernel, bias ~ posterior
  outputs = activation(matmul(inputs, kernel) + bias)
  ```
  
  The arguments permit separate specification of the surrogate posterior
  (`q(W|x)`), prior (`p(W)`), and divergence for both the `kernel` and `bias`
  distributions.
docstr: Construct layer.
  
  Args:
    ${args}
docstr_tok: ["Construct","layer",".","Args",":","$","{","args","}"]
code: def __init__(
      self,
      units,
      activation=None,
      activity_regularizer=None,
      kernel_posterior_fn=tfp_layers_util.default_mean_field_normal_fn(),
      kernel_posterior_tensor_fn=lambda d: d.sample(),
      kernel_prior_fn=tfp_layers_util.default_multivariate_normal_fn,
      kernel_divergence_fn=lambda q, p, ignore: kl_lib.kl_divergence(
          q, p
      ),
      bias_posterior_fn=tfp_layers_util.default_mean_field_normal_fn(
          is_singular=True
      ),
      bias_posterior_tensor_fn=lambda d: d.sample(),
      bias_prior_fn=None,
      bias_divergence_fn=lambda q, p, ignore: kl_lib.kl_divergence(
          q, p
      ),
      **kwargs,
  ):
      # pylint: disable=g-doc-args
      """Construct layer.
  
      Args:
        ${args}
      """
      # pylint: enable=g-doc-args
      super(_DenseVariational, self).__init__(
          activity_regularizer=activity_regularizer, **kwargs
      )
      self.units = units
      self.activation = tf_keras.activations.get(activation)
      self.input_spec = tf_keras.layers.InputSpec(min_ndim=2)
      self.kernel_posterior_fn = kernel_posterior_fn
      self.kernel_posterior_tensor_fn = kernel_posterior_tensor_fn
      self.kernel_prior_fn = kernel_prior_fn
      self.kernel_divergence_fn = kernel_divergence_fn
      self.bias_posterior_fn = bias_posterior_fn
      self.bias_posterior_tensor_fn = bias_posterior_tensor_fn
      self.bias_prior_fn = bias_prior_fn
      self.bias_divergence_fn = bias_divergence_fn
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python import random
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import docstring_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.layers import util
  from tensorflow_probability.python.util import SeedStream
label_desc: Use image node_id 1 to create a new _DenseVariational object from inherited base classes: tf_keras.layers with example: obj = _DenseVariational(units, activation, activity_regularizer, kernel_posterior_fn, kernel_posterior_tensor_fn, kernel_prior_fn, kernel_divergence_fn, bias_posterior_fn, bias_posterior_tensor_fn, bias_prior_fn, bias_divergence_fn)