class_docstr: Layer of our BNN.
class_docstr_tok: ["Layer","of","our","BNN","."]
docstr: Optimization process
docstr_tok: ["Optimization","process"]
code: def forward(self, x: torch.Tensor):
      """
      Optimization process
      """
      # sample weights
      w_epsilon = Normal(0, 1).sample(self.w_mu.shape)
      self.w = (
          self.w_mu + torch.log(1 + torch.exp(self.w_rho)) * w_epsilon
      )
  
      # sample bias
      b_epsilon = Normal(0, 1).sample(self.b_mu.shape)
      self.b = (
          self.b_mu + torch.log(1 + torch.exp(self.b_rho)) * b_epsilon
      )
  
      # record log prior by evaluating log pdf of prior at sampled weight and bias
      w_log_prior = self.prior.log_prob(self.w)
      b_log_prior = self.prior.log_prob(self.b)
      self.log_prior = torch.sum(w_log_prior) + torch.sum(b_log_prior)
  
      # record log variational posterior by evaluating log pdf of normal distribution defined by parameters with respect at the sampled values
      self.w_post = Normal(
          self.w_mu.data, torch.log(1 + torch.exp(self.w_rho))
      )
      self.b_post = Normal(
          self.b_mu.data, torch.log(1 + torch.exp(self.b_rho))
      )
      self.log_post = (
          self.w_post.log_prob(self.w).sum()
          + self.b_post.log_prob(self.b).sum()
      )
  
      return F.linear(x, self.w, self.b)
  
imports: import logging
  from typing import List
  import torch
  import torch.nn
  import torch.nn.functional
  from reagent.models.base import ModelBase
  from reagent.models.fully_connected_network import ACTIVATION_MAP, gaussian_fill_w_gain, SlateBatchNorm1d
  from torch.distributions import Normal
label_desc: Use image node_id 2 for calling the LinearBBB obj's underlying member method code with example usage: obj.forward(x) and returns: F