class_docstr: ## Auto regressive model
class_docstr_tok: ["#","#","Auto","regressive","model"]
code: def __init__(
      self,
      src_embed: Module,
      encoder: Encoder,
      generator: Generator,
      *,
      is_save_ff_input: bool = False,
  ):
      super().__init__()
      # Token embedding module
      self.src_embed = src_embed
      # Transformer based encoder
      self.encoder = encoder
      # Whether the last layer of the encoder should
      # save the input to the feed-forward layer.
      # This is out $f(c_t)$, the embedding of the context.
      self.encoder.layers[-1].is_save_ff_input = is_save_ff_input
      # Next token generation layer;
      # this give logits  of the the next token
      self.generator = generator
      # This will be initialized on the first call
      self.src_mask = None
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/knn/train_model.py
imports: import torch
  from labml import experiment
  from labml.configs import option
  from labml.utils.pytorch import get_modules
  from labml_helpers.module import Module
  from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs
  from labml_nn.transformers import Encoder, Generator, TransformerConfigs
  from labml_nn.transformers.utils import subsequent_mask
label_desc: Use image node_id 1 to create a new AutoregressiveModel object from inherited base classes: Module with example: obj = AutoregressiveModel(src_embed, encoder, generator)