class_docstr: ## FFN module
class_docstr_tok: ["#","#","FFN","module"]
code: def forward(self, x: torch.Tensor):
      # $f(x W_1 + b_1)$
      g = self.activation(self.layer1(x))
      # If gated, $f(x W_1 + b_1) \otimes (x V + b) $
      if self.is_gated:
          x = g * self.linear_v(x)
      # Otherwise
      else:
          x = g
      # Apply dropout
      x = self.dropout(x)
      # $(f(x W_1 + b_1) \otimes (x V + b)) W_2 + b_2$ or $f(x W_1 + b_1) W_2 + b_2$
      # depending on whether it is gated
      return self.layer2(x)
  
imports: import torch
  from torch import nn
  from labml_helpers.module import Module
label_desc: Use image node_id 2 for calling the FeedForward obj's underlying member method code with example usage: obj.forward(x) and returns: self