code: def main(args):
      # --- CONFIG
      device = torch.device(
          f"cuda:{args.cuda}"
          if torch.cuda.is_available() and args.cuda >= 0
          else "cpu"
      )
  
      # --- BENCHMARK CREATION
      benchmark = SplitMNIST(n_experiences=10, seed=1234)
      # ---------
  
      # MODEL CREATION
      model = MlpVAE((1, 28, 28), nhid=2, device=device)
  
      # CREATE THE STRATEGY INSTANCE (GenerativeReplay)
      cl_strategy = VAETraining(
          model,
          torch.optim.Adam(model.parameters(), lr=0.001),
          train_mb_size=100,
          train_epochs=4,
          device=device,
          plugins=[GenerativeReplayPlugin()],
      )
  
      # TRAINING LOOP
      print("Starting experiment...")
      f, axarr = plt.subplots(benchmark.n_experiences, 10)
      k = 0
      for experience in benchmark.train_stream:
          print("Start of experience ", experience.current_experience)
          cl_strategy.train(experience)
          print("Training completed")
  
          samples = model.generate(10)
          samples = samples.detach().cpu().numpy()
  
          for j in range(10):
              axarr[k, j].imshow(samples[j, 0], cmap="gray")
              axarr[k, 4].set_title(
                  "Generated images for experience " + str(k)
              )
          np.vectorize(lambda ax: ax.axis("off"))(axarr)
          k += 1
  
      f.subplots_adjust(hspace=1.2)
      plt.savefig("VAE_output_per_exp")
      plt.show()
  
file_path: avalanche/examples/generative_replay_MNIST_generator.py
imports: import argparse
  import torch
  import torch.optim.lr_scheduler
  import matplotlib.pyplot
  import numpy
  from avalanche.benchmarks import SplitMNIST
  from avalanche.models import MlpVAE
  from avalanche.training.supervised import VAETraining
  from avalanche.training.plugins import GenerativeReplayPlugin
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types