code: def _group_experiences_by_stream(
      eval_streams: Iterable[
          Union[Iterable[CLExperience], CLExperience]
      ]
  ) -> List[List[CLExperience]]:
      exps: List[CLExperience] = []
      # First, we unpack the list of experiences.
      for exp in eval_streams:
          if isinstance(exp, Iterable):
              exps.extend(exp)
          else:
              exps.append(exp)
      # Then, we group them by stream.
      exps_by_stream = defaultdict(list)
      for exp in exps:
          sname = exp.origin_stream.name
          exps_by_stream[sname].append(exp)
      # Finally, we return a list of lists.
      return list(list(exps_by_stream.values()))
  
imports: import sys
  import warnings
  from collections import defaultdict
  from typing import Iterable, Sequence, Optional, TypeVar, Union, List
  import torch
  from torch.nn import Module
  from avalanche.benchmarks import CLExperience, CLStream
  from avalanche.core import BasePlugin
  from avalanche.distributed.distributed_helper import DistributedHelper
  from avalanche.training.templates.strategy_mixin_protocol import BaseStrategyProtocol
  from avalanche.training.utils import trigger_plugins
label_desc: Use image node_id 1 for calling a global function with example usage: _group_experiences_by_stream(eval_streams) and returns: list