class_docstr: Abstract nD convolution layer (private, used as implementation base).
  
  This layer creates a convolution kernel that is convolved
  (actually cross-correlated) with the layer input to produce a tensor of
  outputs. It may also include a bias addition and activation function
  on the outputs. It assumes the `kernel` and/or `bias` are drawn from
  distributions.
  
  By default, the layer implements a stochastic forward pass via
  sampling from the kernel and bias posteriors,
  ```none
  outputs = f(inputs; kernel, bias), kernel, bias ~ posterior
  ```
  where f denotes the layer's calculation.
  
  The arguments permit separate specification of the surrogate posterior
  (`q(W|x)`), prior (`p(W)`), and divergence for both the `kernel` and `bias`
  distributions.
class_docstr_tok: ["Abstract","nD","convolution","layer","(","private",",","used","as","implementation","base",")",".","This","layer","creates","a","convolution","kernel","that","is","convolved","(","actually","cross-correlated",")","with","the","layer","input","to","produce","a","tensor","of","outputs",".","It","may","also","include","a","bias","addition","and","activation","function","on","the","outputs",".","It","assumes","the","`","kernel","`","and\/or","`","bias","`","are","drawn","from","distributions",".","By","default",",","the","layer","implements","a","stochastic","forward","pass","via","sampling","from","the","kernel","and","bias","posteriors",",","``","`","none","outputs","=","f","(","inputs",";","kernel",",","bias",")",",","kernel",",","bias","~","posterior","``","`","where","f","denotes","the","layer","'s","calculation",".","The","arguments","permit","separate","specification","of","the","surrogate","posterior","(","`","q","(","W|x",")","`",")",",","prior","(","`","p","(","W",")","`",")",",","and","divergence","for","both","the","`","kernel","`","and","`","bias","`","distributions","."]
code: def _apply_variational_bias(self, inputs):
      if self.bias_posterior is None:
          self.bias_posterior_tensor = None
          return inputs
      self.bias_posterior_tensor = self.bias_posterior_tensor_fn(
          self.bias_posterior
      )
      outputs = inputs
      if self.data_format == "channels_first":
          if self.rank == 1:
              # tf.nn.bias_add does not accept a 1D input tensor.
              bias = tf.reshape(
                  self.bias_posterior_tensor, [1, self.filters, 1]
              )
              outputs += bias
          if self.rank == 2:
              outputs = tf.nn.bias_add(
                  outputs,
                  self.bias_posterior_tensor,
                  data_format="NCHW",
              )
          if self.rank == 3:
              # As of Mar 2017, direct addition is significantly slower than
              # bias_add when computing gradients. To use bias_add, we collapse Z
              # and Y into a single dimension to obtain a 4D input tensor.
              outputs_shape = tf.shape(outputs)
              outputs_4d = tf.reshape(
                  outputs,
                  [
                      outputs_shape[0],
                      outputs_shape[1],
                      outputs_shape[2] * outputs_shape[3],
                      outputs_shape[4],
                  ],
              )
              outputs_4d = tf.nn.bias_add(
                  outputs_4d,
                  self.bias_posterior_tensor,
                  data_format="NCHW",
              )
              outputs = tf.reshape(outputs_4d, outputs_shape)
      else:
          outputs = tf.nn.bias_add(
              outputs, self.bias_posterior_tensor, data_format="NHWC"
          )
      return outputs
  
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.seed_stream import SeedStream
  from tensorflow.python.ops import nn_ops
label_desc: Use image node_id 7 for calling the _ConvVariational obj's underlying member method code with example usage: obj._apply_variational_bias(inputs) and returns: outputs, inputs