class_docstr: ## Auto regressive model
class_docstr_tok: ["#","#","Auto","regressive","model"]
code: def forward(self, src: torch.Tensor):
      # Create subsequent mask, so that the transformer can only pay attention to past tokens.
      if self.src_mask is None or self.src_mask.size(0) != len(src):
          self.src_mask = subsequent_mask(len(src)).to(src.device)
      # Embed the tokens (`src`) and run it through the the transformer
      res = self.encoder(self.src_embed(src), self.src_mask)
      # Generate logits of the next token
      return self.generator(res), 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 3 for calling the AutoregressiveModel obj's underlying member method code with example usage: obj.forward(src) and returns: self,  None