class_docstr: Dynamic Modules are Avalanche modules that can be incrementally
  expanded to allow architectural modifications (multi-head
  classifiers, progressive networks, ...).
  
  Compared to pytoch Modules, they provide an additional method,
  `model_adaptation`, which adapts the model given the current experience.
class_docstr_tok: ["Dynamic","Modules","are","Avalanche","modules","that","can","be","incrementally","expanded","to","allow","architectural","modifications","(","multi-head","classifiers",",","progressive","networks",",","...",")",".","Compared","to","pytoch","Modules",",","they","provide","an","additional","method",",","`","model_adaptation","`",",","which","adapts","the","model","given","the","current","experience","."]
docstr: Adapt the module (freeze units, add units...) using the current
  data. Optimizers must be updated after the model adaptation.
  
  Avalanche strategies call this method to adapt the architecture
  *before* processing each experience. Strategies also update the
  optimizer automatically.
  
  .. warning::
      As a general rule, you should NOT use this method to train the
      model. The dataset should be used only to check conditions which
      require the model's adaptation, such as the discovery of new
      classes or tasks.
  
  :param experience: the current experience.
  :return:
docstr_tok: ["Adapt","the","module","(","freeze","units",",","add","units","...",")","using","the","current","data",".","Optimizers","must","be","updated","after","the","model","adaptation",".","Avalanche","strategies","call","this","method","to","adapt","the","architecture","*","before","*","processing","each","experience",".","Strategies","also","update","the","optimizer","automatically",".","..","warning",":",":","As","a","general","rule",",","you","should","NOT","use","this","method","to","train","the","model",".","The","dataset","should","be","used","only","to","check","conditions","which","require","the","model","'s","adaptation",",","such","as","the","discovery","of","new","classes","or","tasks",".",":","param","experience",":","the","current","experience",".",":","return",":"]
code: def adaptation(self, experience: CLExperience):
      """Adapt the module (freeze units, add units...) using the current
      data. Optimizers must be updated after the model adaptation.
  
      Avalanche strategies call this method to adapt the architecture
      *before* processing each experience. Strategies also update the
      optimizer automatically.
  
      .. warning::
          As a general rule, you should NOT use this method to train the
          model. The dataset should be used only to check conditions which
          require the model's adaptation, such as the discovery of new
          classes or tasks.
  
      :param experience: the current experience.
      :return:
      """
      if self.training:
          self.train_adaptation(experience)
      else:
          self.eval_adaptation(experience)
  
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 1 for calling the DynamicModule obj's underlying member method code with example usage: obj.adaptation(experience) without return types