class_docstr: ## Configurations
  
  The default configurations can and will be overridden when we start the experiment.
class_docstr_tok: ["#","#","Configurations","The","default","configurations","can","and","will","be","overridden","when","we","start","the","experiment","."]
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)]
      # memory
      mem = CompressedMemory([], [])
      # Sample 25 tokens
      for i in monit.iterate("Sample", 25):
          # Tokenize the prompt
          data = self.text.text_to_i(prompt).unsqueeze(-1)
          # Move to device
          data = data.to(self.device)
          # Get the model output
          output, new_mem = self.model(data, mem)
          # Get the model prediction (greedy)
          output = output.argmax(dim=-1).squeeze(1)
          # Add the prediction to prompt
          prompt += self.prompt_separator + self.text.itos[output[-1]]
          # Only feed the last character to model in next iteration, rest will go in as memories
          prompt = prompt[-1:]
          # Add the prediction for logging
          log += [
              (
                  self.prompt_separator + self.text.itos[output[-1]],
                  Text.value,
              )
          ]
          # Update and compress memory
          mem, _ = self.merge_compress_memory(mem, new_mem)
  
      # Print the sampled output
      logger.log(log)
  
imports: from typing import List, Tuple, NamedTuple
  import torch
  import torch.nn
  from labml import experiment, tracker, monit, logger
  from labml.configs import option
  from labml.logger import Text
  from labml_helpers.metrics.simple_state import SimpleStateModule
  from labml_helpers.module import Module
  from labml_helpers.train_valid import BatchIndex, hook_model_outputs
  from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs
  from labml_nn.transformers.compressive import CompressiveTransformer, AttentionReconstructionLoss, CompressiveTransformerLayer, Conv1dCompression
label_desc: Use image node_id 4 for calling the Configs obj's underlying member method code with example usage: obj.sample() without return types