class_docstr: ## Feedback Transformer Module
class_docstr_tok: ["#","#","Feedback","Transformer","Module"]
docstr: * `layer` is the feedback transformer layer, which we clone for each layer
  * `n_layers` is the number of layers in the transformer
docstr_tok: ["*","`","layer","`","is","the","feedback","transformer","layer",",","which","we","clone","for","each","layer","*","`","n_layers","`","is","the","number","of","layers","in","the","transformer"]
code: def __init__(self, layer: FeedbackTransformerLayer, n_layers: int):
      """
      * `layer` is the feedback transformer layer, which we clone for each layer
      * `n_layers` is the number of layers in the transformer
      """
  
      super().__init__()
      # Make copies of the transformer layer
      self.layers = clone_module_list(layer, n_layers)
      # Final normalization layer
      self.norm = nn.LayerNorm([layer.size])
      # Memory vectors are computed as a weighted sum of representations of each layer.
      # This is the weights parameter for that.
      self.weights = nn.Parameter(
          torch.ones(n_layers + 1), requires_grad=True
      )
      # Softmax for weights before taking the weighted sum
      self.softmax = nn.Softmax(0)
  
imports: import math
  from typing import Optional
  import torch
  from torch import nn
  from labml_helpers.module import Module
  from labml_nn.transformers.feed_forward import FeedForward
  from labml_nn.transformers.mha import PrepareForMultiHeadAttention
  from labml_nn.utils import clone_module_list
label_desc: Use image node_id 1 to create a new FeedbackTransformer object from inherited base classes: Module with example: obj = FeedbackTransformer(layer, n_layers)