code: def main(args):
      # Device config
      device = torch.device(
          f"cuda:{args.cuda}"
          if torch.cuda.is_available() and args.cuda >= 0
          else "cpu"
      )
  
      # model
      model = SimpleMLP(num_classes=10)
  
      # Here we show all the MNIST variation we offer in the "classic" benchmarks
      if args.mnist_type == "permuted":
          benchmark = PermutedMNIST(n_experiences=5, seed=1)
      elif args.mnist_type == "rotated":
          benchmark = RotatedMNIST(
              n_experiences=5,
              rotations_list=[30, 60, 90, 120, 150],
              seed=1,
          )
      else:
          benchmark = SplitMNIST(n_experiences=5, seed=1)
  
      # Than we can extract the parallel train and test streams
      train_stream = benchmark.train_stream
      test_stream = benchmark.test_stream
  
      # Prepare for training & testing
      optimizer = SGD(model.parameters(), lr=0.001, momentum=0.9)
      criterion = CrossEntropyLoss()
  
      # Continual learning strategy with default logger
      cl_strategy = Naive(
          model,
          optimizer,
          criterion,
          train_mb_size=32,
          train_epochs=100,
          eval_mb_size=32,
          device=device,
          eval_every=1,
          plugins=[EarlyStoppingPlugin(args.patience, "test_stream")],
      )
  
      # train and test loop
      results = []
      for train_task, test_task in zip(train_stream, test_stream):
          print(
              "Current Classes: ", train_task.classes_in_this_experience
          )
          cl_strategy.train(train_task, eval_streams=[test_task])
          results.append(cl_strategy.eval(test_stream))
  
file_path: avalanche/examples/all_mnist_early_stopping.py
imports: import torch
  import argparse
  from torch.nn import CrossEntropyLoss
  from torch.optim import SGD
  from avalanche.benchmarks.classic import PermutedMNIST, RotatedMNIST, SplitMNIST
  from avalanche.models import SimpleMLP
  from avalanche.training.plugins.early_stopping import EarlyStoppingPlugin
  from avalanche.training.supervised import Naive
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types