class_docstr: Bias Correction (BiC) plugin.
  
  Technique introduced in:
  "Wu, Yue, et al. "Large scale incremental learning." Proceedings
  of the IEEE/CVF Conference on Computer Vision and Pattern
  Recognition. 2019"
  
  Implementation based on FACIL, as in:
  https://github.com/mmasana/FACIL/blob/master/src/approach/bic.py
code: def before_train_dataset_adaptation(
      self, strategy: "SupervisedTemplate", **kwargs
  ):
      assert strategy.experience is not None
      new_data: AvalancheDataset = strategy.experience.dataset
      task_id = strategy.clock.train_exp_counter
  
      cl_idxs: Dict[int, List[int]] = defaultdict(list)
      targets: Sequence[SupportsInt] = getattr(new_data, "targets")
      for idx, target in enumerate(targets):
          # Conversion to int may fix issues when target
          # is a single-element torch.tensor
          target = int(target)
          cl_idxs[target].append(idx)
  
      for c in cl_idxs.keys():
          self.class_to_tasks[c] = task_id
  
      self.seen_classes.update(cl_idxs.keys())
      lens = self.get_group_lengths(len(self.seen_classes))
      class_to_len = {}
      for class_id, ll in zip(self.seen_classes, lens):
          class_to_len[class_id] = ll
  
      train_data = []
      for class_id in cl_idxs.keys():
          ll = class_to_len[class_id]
          new_data_c = new_data.subset(cl_idxs[class_id][:ll])
          if class_id in self.val_buffer:
              old_buffer_c = self.val_buffer[class_id]
              old_buffer_c.update_from_dataset(new_data_c)
              old_buffer_c.resize(strategy, ll)
          else:
              new_buffer = ReservoirSamplingBuffer(ll)
              new_buffer.update_from_dataset(new_data_c)
              self.val_buffer[class_id] = new_buffer
  
          train_data.append(new_data.subset(cl_idxs[class_id][ll:]))
  
      # resize buffers
      for class_id, class_buf in self.val_buffer.items():
          class_buf.resize(strategy, class_to_len[class_id])
  
      strategy.experience.dataset = (
          _concat_taskaware_classification_datasets(train_data)
      )
  
imports: from collections import defaultdict
  from typing import Dict, List, Optional, TYPE_CHECKING, Sequence, Set, SupportsInt
  from copy import deepcopy
  import torch
  from torch.utils.data import DataLoader
  from torch.optim.lr_scheduler import MultiStepLR
  from avalanche.benchmarks.utils import _taskaware_classification_subset, _concat_taskaware_classification_datasets
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.data_loader import ReplayDataLoader
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
  from avalanche.training.storage_policy import ExemplarsBuffer, ExperienceBalancedBuffer, ReservoirSamplingBuffer
  from avalanche.models.dynamic_modules import MultiTaskModule
  from avalanche.models.bic_model import BiasLayer
label_desc: Use image node_id 3 for calling the BiCPlugin obj's underlying member method code with example usage: obj.before_train_dataset_adaptation(strategy) without return types