code: def benchmark_ffcv_speed(
      benchmark, path, device, batch_size=128, num_workers=1, epochs=1
  ):
      print("Testing FFCV Loader speed")
  
      all_train_dataset = [x.dataset for x in benchmark.train_stream]
      avl_set = AvalancheDataset(all_train_dataset)
      avl_set = avl_set.train()
  
      start_time = time.time()
      enable_ffcv(
          benchmark,
          path,
          device,
          dict(num_workers=num_workers),
          print_summary=False,  # Better keep this true on non-benchmarking code
      )
      end_time = time.time()
      print("FFCV preparation time:", end_time - start_time, "seconds")
  
      start_time = time.time()
      ffcv_loader = HybridFfcvLoader(
          dataset=avl_set,
          batch_sampler=BatchSampler(
              SequentialSampler(avl_set),
              batch_size=batch_size,
              drop_last=True,
          ),
          ffcv_loader_parameters=dict(num_workers=num_workers),
          device=device,
          print_ffcv_summary=False,
      )
  
      for _ in tqdm(range(epochs)):
          for batch in tqdm(ffcv_loader):
              # "Touch" tensors to make sure they already moved to GPU
              batch[0][0]
              batch[-1][0]
  
      end_time = time.time()
      print("FFCV time:", end_time - start_time, "seconds")
  
file_path: avalanche/examples/ffcv/ffcv_try_speed.py
imports: import argparse
  import time
  from typing import Tuple
  import torch
  import torch.optim.lr_scheduler
  from avalanche.benchmarks import SplitMNIST
  from avalanche.benchmarks.classic.ccifar100 import SplitCIFAR100
  from avalanche.benchmarks.classic.core50 import CORe50
  from avalanche.benchmarks.classic.ctiny_imagenet import SplitTinyImageNet
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.ffcv_support import HybridFfcvLoader, enable_ffcv
  from avalanche.training.determinism.rng_manager import RNGManager
  from ffcv.transforms import ToTensor
  from torchvision.transforms import Compose, ToTensor, Normalize
  from torch.utils.data import DataLoader
  from torch.utils.data.sampler import BatchSampler, SequentialSampler
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: benchmark_ffcv_speed(benchmark, path, device, batch_size, num_workers, epochs) without return types