class_docstr: <a id="NLPAutoRegressionConfigs"></a>
  
  ## Trainer configurations
  
  This has the basic configurations for NLP auto-regressive task training.
  All the properties are configurable.
class_docstr_tok: ["<","a","id=","''","NLPAutoRegressionConfigs","''",">","<","\/a",">","#","#","Trainer","configurations","This","has","the","basic","configurations","for","NLP","auto-regressive","task","training",".","All","the","properties","are","configurable","."]
docstr: ### Sampling function to generate samples periodically while training
docstr_tok: ["#","#","#","Sampling","function","to","generate","samples","periodically","while","training"]
code: def sample(self):
      """
      ### Sampling function to generate samples periodically while training
      """
  
      # Starting prompt
      prompt = self.prompt
      # Collect output for printing
      log = [(prompt, Text.subtle)]
      # Sample 25 tokens
      for i in monit.iterate("Sample", 25):
          # Tokenize the prompt
          data = self.text.text_to_i(prompt).unsqueeze(-1)
          data = data.to(self.device)
          # Get the model output
          output, *_ = self.model(data)
          # Get the model prediction (greedy)
          output = output.argmax(dim=-1).squeeze()
          # Add the prediction to prompt
          prompt += self.prompt_separator + self.text.itos[output[-1]]
          # Add the prediction for logging
          log += [
              (
                  self.prompt_separator + self.text.itos[output[-1]],
                  Text.value,
              )
          ]
  
      tracker.add({"sampled": prompt})
      # Print the sampled output
      logger.log(log)
  
imports: from typing import Callable
  import torch
  import torch.nn
  from torch.utils.data import DataLoader, RandomSampler
  from labml import lab, monit, logger, tracker
  from labml.configs import option
  from labml.logger import Text
  from labml_helpers.datasets.text import TextDataset, SequentialDataLoader, SequentialUnBatchedDataset, TextFileDataset
  from labml_helpers.device import DeviceConfigs
  from labml_helpers.metrics.accuracy import Accuracy
  from labml_helpers.module import Module
  from labml_helpers.train_valid import TrainValidConfigs, hook_model_outputs, BatchIndex
  from labml_nn.optimizers.configs import OptimizerConfigs
label_desc: Use image node_id 4 for calling the NLPAutoRegressionConfigs obj's underlying member method code with example usage: obj.sample() without return types