class_docstr: Output layer that incrementally adds units whenever new classes are
  encountered.
  
  Typically used in class-incremental benchmarks where the number of
  classes grows over time.
class_docstr_tok: ["Output","layer","that","incrementally","adds","units","whenever","new","classes","are","encountered",".","Typically","used","in","class-incremental","benchmarks","where","the","number","of","classes","grows","over","time","."]
docstr: If `dataset` contains unseen classes the classifier is expanded.
  
  :param experience: data from the current experience.
  :return:
docstr_tok: ["If","`","dataset","`","contains","unseen","classes","the","classifier","is","expanded",".",":","param","experience",":","data","from","the","current","experience",".",":","return",":"]
code: def adaptation(self, experience: CLExperience):
      """If `dataset` contains unseen classes the classifier is expanded.
  
      :param experience: data from the current experience.
      :return:
      """
      device = self._adaptation_device
      in_features = self.classifier.in_features
      old_nclasses = self.classifier.out_features
      curr_classes = experience.classes_in_this_experience
      new_nclasses = max(
          self.classifier.out_features, max(curr_classes) + 1
      )
  
      # update active_units mask
      if self.masking:
          if old_nclasses != new_nclasses:  # expand active_units mask
              old_act_units = self.active_units
              self.active_units = torch.zeros(
                  new_nclasses, dtype=torch.int8, device=device
              )
              self.active_units[
                  : old_act_units.shape[0]
              ] = old_act_units
          # update with new active classes
          if self.training:
              self.active_units[curr_classes] = 1
  
      # update classifier weights
      if old_nclasses == new_nclasses:
          return
      old_w, old_b = self.classifier.weight, self.classifier.bias
      self.classifier = torch.nn.Linear(in_features, new_nclasses).to(
          device
      )
      self.classifier.weight[:old_nclasses] = old_w
      self.classifier.bias[:old_nclasses] = old_b
  
imports: import torch
  from torch.nn import Module
  from typing import Optional
  from avalanche.benchmarks.utils.flat_data import ConstantSequence
  from avalanche.benchmarks.scenarios import CLExperience
label_desc: Use image node_id 2 for calling the IncrementalClassifier obj's underlying member method code with example usage: obj.adaptation(experience) without return types