code: def test_ni_unbalanced(self):
      num_exp, num_classes = 5, 10
      d1, d2 = dummy_classification_datasets(n_classes=num_classes)
      bm = new_instances_benchmark(
          d1,
          d2,
          num_experiences=num_exp,
          shuffle=True,
          seed=1234,
          balance_experiences=False,
      )
      bm = with_classes_timeline(bm)
  
      # TODO: fix pycharm types?
      self.assertEqual(5, len(list(bm.train_stream)))
      for exp in bm.train_stream:
          self.assertEqual(10, len(exp.classes_in_this_experience))
  
      _, unique_count = torch.unique(
          torch.as_tensor(d1.targets), return_counts=True
      )
  
      min_exp_size = torch.sum(unique_count // num_exp).item()
      max_exp_size = min_exp_size + num_classes
  
      pattern_count = 0
      for batch_id, exp in enumerate(bm.train_stream):
          cur_train_set = exp.dataset
          self.assertEqual(batch_id, exp.current_experience)
          self.assertGreaterEqual(len(cur_train_set), min_exp_size)
          self.assertLessEqual(len(cur_train_set), max_exp_size)
          pattern_count += len(cur_train_set)
      self.assertEqual(len(d1), pattern_count)
  
      self.assertEqual(1, len(bm.test_stream))
      pattern_count = 0
      for batch_id, exp in enumerate(bm.test_stream):
          cur_test_set = exp.dataset
          self.assertEqual(batch_id, exp.current_experience)
          pattern_count += len(cur_test_set)
      self.assertEqual(len(d2), pattern_count)
  
file_path: avalanche/tests/benchmarks/scenarios/test_supervised_scenario.py
imports: import unittest
  import torch
  from avalanche.benchmarks.scenarios import _split_dataset_by_attribute
  from avalanche.benchmarks.scenarios.supervised import class_incremental_benchmark, new_instances_benchmark, with_classes_timeline
  from avalanche.benchmarks.utils import _make_taskaware_tensor_classification_dataset
  from tests.unit_tests_utils import dummy_classification_datasets
label_desc: Use image node_id 2 for calling the NewInstancesTests obj's underlying member method code with example usage: obj.test_ni_unbalanced() without return types