code: def main():
      """
      ### Try different sampling techniques
      """
  
      # Load the model and tokenizer
      with monit.section("Load tokenizer/model"):
          tokenizer = GPT2Tokenizer.from_pretrained(
              "gpt2", cache_dir=lab.get_data_path() / "cache"
          )
          model = GPT2LMHeadModel.from_pretrained(
              "gpt2", cache_dir=lab.get_data_path() / "cache"
          )
      # Set the model to eval mode
      model.eval()
  
      # Prompts to use for sampling
      prompt = "I saw an interesting dream last night. "
  
      # [Greedy Sampling](greedy.html)
      with monit.section("greedy"):
          sample(model, tokenizer, GreedySampler(), 4, 32, 128, prompt)
  
      # [Temperature Sampling](temperature.html)
      with monit.section("temperature=1."):
          sample(
              model,
              tokenizer,
              TemperatureSampler(1.0),
              4,
              32,
              128,
              prompt,
          )
      with monit.section("temperature=.1"):
          sample(
              model,
              tokenizer,
              TemperatureSampler(0.1),
              4,
              32,
              128,
              prompt,
          )
      with monit.section("temperature=10."):
          sample(
              model,
              tokenizer,
              TemperatureSampler(10.0),
              4,
              32,
              128,
              prompt,
          )
  
      # [Top-k Sampling](top_k.html)
      with monit.section("top_k=5"):
          sample(
              model,
              tokenizer,
              TopKSampler(2, TemperatureSampler(1.0)),
              4,
              32,
              128,
              prompt,
          )
  
      # [Nucleus Sampling](nucleus.html)
      with monit.section("nucleus p=.95"):
          sample(
              model,
              tokenizer,
              NucleusSampler(0.95, TemperatureSampler(1.0)),
              4,
              32,
              128,
              prompt,
          )
      with monit.section("nucleus p=.1"):
          sample(
              model,
              tokenizer,
              NucleusSampler(0.1, TemperatureSampler(1.0)),
              4,
              32,
              128,
              prompt,
          )
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/sampling/experiment.py
imports: import torch
  from labml import monit, logger, lab
  from labml.logger import Text
  from labml_nn.sampling import Sampler
  from labml_nn.sampling.greedy import GreedySampler
  from labml_nn.sampling.nucleus import NucleusSampler
  from labml_nn.sampling.temperature import TemperatureSampler
  from labml_nn.sampling.top_k import TopKSampler
  from transformers import GPT2Tokenizer, GPT2LMHeadModel
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types