class_docstr: ## Auto-Regressive model
class_docstr_tok: ["#","#","Auto-Regressive","model"]
code: def forward(self, x: torch.Tensor):
      # Create subsequent mask if mask is not initialized
      # or if the size of the mask is different
      if self.mask is None or self.mask.size(0) != len(x):
          # Subsequent mask, will mask out tokens from seeing future tokens
          self.mask = subsequent_mask(len(x)).to(x.device)
      # Get the token embeddings with positional encodings
      x = self.src_embed(x)
      # Transformer encoder
      x = self.encoder(x, self.mask)
      # Get logits
      x = self.generator(x)
  
      # Return results
      # (second value is for state, since our trainer is used with RNNs also)
      return x, None
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/basic/autoregressive_experiment.py
imports: import torch
  from torch import nn
  from labml import experiment
  from labml.configs import option
  from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs
  from labml_nn.transformers import TransformerConfigs, Encoder
  from labml_nn.transformers.utils import subsequent_mask
label_desc: Use image node_id 2 for calling the AutoregressiveTransformer obj's underlying member method code with example usage: obj.forward(x) and returns: x,  None