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. It uses the Flipout
  estimator [(Wen et al., 2018)][1], which performs a Monte Carlo approximation
  of the distribution integrating over the `kernel` and `bias`. Flipout uses
  roughly twice as many floating point operations as the reparameterization
  estimator but has the advantage of significantly lower variance.
  
  The arguments permit separate specification of the surrogate posterior
  (`q(W|x)`), prior (`p(W)`), and divergence for both the `kernel` and `bias`
  distributions.
  
  #### References
  
  [1]: Yeming Wen, Paul Vicol, Jimmy Ba, Dustin Tran, and Roger Grosse. Flipout:
       Efficient Pseudo-Independent Weight Perturbations on Mini-Batches. In
       _International Conference on Learning Representations_, 2018.
       https://arxiv.org/abs/1803.04386
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",".","It","uses","the","Flipout","estimator","[","(","Wen","et","al.",",","2018",")","]","[","1","]",",","which","performs","a","Monte","Carlo","approximation","of","the","distribution","integrating","over","the","`","kernel","`","and","`","bias","`",".","Flipout","uses","roughly","twice","as","many","floating","point","operations","as","the","reparameterization","estimator","but","has","the","advantage","of","significantly","lower","variance",".","The","arguments","permit","separate","specification","of","the","surrogate","posterior","(","`","q","(","W|x",")","`",")",",","prior","(","`","p","(","W",")","`",")",",","and","divergence","for","both","the","`","kernel","`","and","`","bias","`","distributions",".","#","#","#","#","References","[","1","]",":","Yeming","Wen",",","Paul","Vicol",",","Jimmy","Ba",",","Dustin","Tran",",","and","Roger","Grosse",".","Flipout",":","Efficient","Pseudo-Independent","Weight","Perturbations","on","Mini-Batches",".","In","_International","Conference","on","Learning","Representations_",",","2018.","https",":","\/\/arxiv.org\/abs\/1803.04386"]
docstr: Construct layer.
  
  Args:
    rank: An integer, the rank of the convolution, e.g. "2" for 2D
      convolution.
    filters: Integer, the dimensionality of the output space (i.e. the number
      of filters in the convolution).
    kernel_size: An integer or tuple/list of n integers, specifying the
      length of the convolution window.
    strides: An integer or tuple/list of n integers,
      specifying the stride length of the convolution.
      Specifying any stride value != 1 is incompatible with specifying
      any `dilation_rate` value != 1.
    padding: One of `"valid"` or `"same"` (case-insensitive).
    data_format: A string, one of `channels_last` (default) or
      `channels_first`. The ordering of the dimensions in the inputs.
      `channels_last` corresponds to inputs with shape `(batch, ...,
      channels)` while `channels_first` corresponds to inputs with shape
      `(batch, channels, ...)`.
    dilation_rate: An integer or tuple/list of n integers, specifying
      the dilation rate to use for dilated convolution.
      Currently, specifying any `dilation_rate` value != 1 is
      incompatible with specifying any `strides` value != 1.
    ${args}
    seed: Python scalar `int` which initializes the random number
      generator. Default value: `None` (i.e., use global seed).
docstr_tok: ["Construct","layer",".","Args",":","rank",":","An","integer",",","the","rank","of","the","convolution",",","e.g",".","``","2","''","for","2D","convolution",".","filters",":","Integer",",","the","dimensionality","of","the","output","space","(","i.e",".","the","number","of","filters","in","the","convolution",")",".","kernel_size",":","An","integer","or","tuple\/list","of","n","integers",",","specifying","the","length","of","the","convolution","window",".","strides",":","An","integer","or","tuple\/list","of","n","integers",",","specifying","the","stride","length","of","the","convolution",".","Specifying","any","stride","value","!","=","1","is","incompatible","with","specifying","any","`","dilation_rate","`","value","!","=","1.","padding",":","One","of","`","``","valid","''","`","or","`","``","same","''","`","(","case-insensitive",")",".","data_format",":","A","string",",","one","of","`","channels_last","`","(","default",")","or","`","channels_first","`",".","The","ordering","of","the","dimensions","in","the","inputs",".","`","channels_last","`","corresponds","to","inputs","with","shape","`","(","batch",",","...",",","channels",")","`","while","`","channels_first","`","corresponds","to","inputs","with","shape","`","(","batch",",","channels",",","...",")","`",".","dilation_rate",":","An","integer","or","tuple\/list","of","n","integers",",","specifying","the","dilation","rate","to","use","for","dilated","convolution",".","Currently",",","specifying","any","`","dilation_rate","`","value","!","=","1","is","incompatible","with","specifying","any","`","strides","`","value","!","=","1",".","$","{","args","}","seed",":","Python","scalar","`","int","`","which","initializes","the","random","number","generator",".","Default","value",":","`","None","`","(","i.e.",",","use","global","seed",")","."]
code: def __init__(
      self,
      rank,
      filters,
      kernel_size,
      strides=1,
      padding="valid",
      data_format="channels_last",
      dilation_rate=1,
      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
      ),
      seed=None,
      **kwargs,
  ):
      # pylint: disable=g-doc-args
      """Construct layer.
  
      Args:
        rank: An integer, the rank of the convolution, e.g. "2" for 2D
          convolution.
        filters: Integer, the dimensionality of the output space (i.e. the number
          of filters in the convolution).
        kernel_size: An integer or tuple/list of n integers, specifying the
          length of the convolution window.
        strides: An integer or tuple/list of n integers,
          specifying the stride length of the convolution.
          Specifying any stride value != 1 is incompatible with specifying
          any `dilation_rate` value != 1.
        padding: One of `"valid"` or `"same"` (case-insensitive).
        data_format: A string, one of `channels_last` (default) or
          `channels_first`. The ordering of the dimensions in the inputs.
          `channels_last` corresponds to inputs with shape `(batch, ...,
          channels)` while `channels_first` corresponds to inputs with shape
          `(batch, channels, ...)`.
        dilation_rate: An integer or tuple/list of n integers, specifying
          the dilation rate to use for dilated convolution.
          Currently, specifying any `dilation_rate` value != 1 is
          incompatible with specifying any `strides` value != 1.
        ${args}
        seed: Python scalar `int` which initializes the random number
          generator. Default value: `None` (i.e., use global seed).
      """
      # pylint: enable=g-doc-args
      super(_ConvFlipout, self).__init__(
          rank=rank,
          filters=filters,
          kernel_size=kernel_size,
          strides=strides,
          padding=padding,
          data_format=data_format,
          dilation_rate=dilation_rate,
          activation=tf_keras.activations.get(activation),
          activity_regularizer=activity_regularizer,
          kernel_posterior_fn=kernel_posterior_fn,
          kernel_posterior_tensor_fn=kernel_posterior_tensor_fn,
          kernel_prior_fn=kernel_prior_fn,
          kernel_divergence_fn=kernel_divergence_fn,
          bias_posterior_fn=bias_posterior_fn,
          bias_posterior_tensor_fn=bias_posterior_tensor_fn,
          bias_prior_fn=bias_prior_fn,
          bias_divergence_fn=bias_divergence_fn,
          **kwargs,
      )
      # Set additional attributes which do not exist in the parent class.
      self.seed = seed
  
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 1 to create a new _ConvFlipout object from inherited base classes: _ConvVariational with example: obj = _ConvFlipout(rank, filters, kernel_size, strides, padding, data_format, dilation_rate, 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, seed)