class_docstr: Elastic Weight Consolidation (EWC) plugin.
  EWC computes importance of each weight at the end of training on current
  experience. During training on each minibatch, the loss is augmented
  with a penalty which keeps the value of the current weights close to the
  value they had on previous experiences in proportion to their importance
  on that experience. Importances are computed with an additional pass on the
  training set. This plugin does not use task identities.
docstr: Update importance for each parameter based on the currently computed
  importances.
docstr_tok: ["Update","importance","for","each","parameter","based","on","the","currently","computed","importances","."]
code: def update_importances(self, importances, t: int):
      """
      Update importance for each parameter based on the currently computed
      importances.
      """
  
      if self.mode == "separate" or t == 0:
          self.importances[t] = importances
      elif self.mode == "online":
          for (k1, old_imp), (k2, curr_imp) in itertools.zip_longest(
              self.importances[t - 1].items(),
              importances.items(),
              fillvalue=(None, None),
          ):
              # Add new module importances to the importances value (New head)
              if k1 is None:
                  assert k2 is not None
                  assert curr_imp is not None
                  self.importances[t][k2] = curr_imp
                  continue
  
              assert k1 == k2, "Error in importance computation."
              assert curr_imp is not None
              assert old_imp is not None
              assert k2 is not None
  
              # manage expansion of existing layers
              self.importances[t][k1] = ParamData(
                  f"imp_{k1}",
                  curr_imp.shape,
                  init_tensor=self.decay_factor
                  * old_imp.expand(curr_imp.shape)
                  + curr_imp.data,
                  device=curr_imp.device,
              )
  
          # clear previous parameter importances
          if t > 0 and (not self.keep_importance_data):
              del self.importances[t - 1]
  
      else:
          raise ValueError("Wrong EWC mode.")
  
file_path: avalanche/avalanche/training/plugins/ewc.py
imports: from collections import defaultdict
  from typing import Dict, Tuple, Union
  import warnings
  import itertools
  import torch
  from torch.utils.data import DataLoader
  from avalanche.models.utils import avalanche_forward
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
  from avalanche.training.utils import copy_params_dict, zerolike_params_dict, ParamData
label_desc: Use image node_id 5 for calling the EWCPlugin obj's underlying member method code with example usage: obj.update_importances(importances, t) without return types