class_docstr: Memory Aware Synapses (MAS) plugin.
  
  Similarly to EWC, the MAS plugin computes the importance of each
  parameter at the end of each experience. The approach computes
  importance via a second pass on the dataset. MAS does not require
  supervision and estimates importance using the gradients of the
  L2 norm of the output. Importance is then used to add a penalty
  term to the loss function.
  
  Technique introduced in:
  "Memory Aware Synapses: Learning what (not) to forget"
  by Aljundi et. al (2018).
  
  Implementation based on FACIL, as in:
  https://github.com/mmasana/FACIL/blob/master/src/approach/mas.py
class_docstr_tok: ["Memory","Aware","Synapses","(","MAS",")","plugin",".","Similarly","to","EWC",",","the","MAS","plugin","computes","the","importance","of","each","parameter","at","the","end","of","each","experience",".","The","approach","computes","importance","via","a","second","pass","on","the","dataset",".","MAS","does","not","require","supervision","and","estimates","importance","using","the","gradients","of","the","L2","norm","of","the","output",".","Importance","is","then","used","to","add","a","penalty","term","to","the","loss","function",".","Technique","introduced","in",":","''","Memory","Aware","Synapses",":","Learning","what","(","not",")","to","forget","''","by","Aljundi","et",".","al","(","2018",")",".","Implementation","based","on","FACIL",",","as","in",":","https",":","\/\/github.com\/mmasana\/FACIL\/blob\/master\/src\/approach\/mas.py"]
code: def after_training_exp(self, strategy, **kwargs):
      self.params = dict(copy_params_dict(strategy.model))
  
      # Get importance
      exp_counter = strategy.clock.train_exp_counter
      if exp_counter == 0:
          self.importance = self._get_importance(strategy)
          return
      else:
          curr_importance = self._get_importance(strategy)
  
      # Check if previous importance is available
      if not self.importance:
          raise ValueError("Importance is not available")
  
      # Update importance
      for name in curr_importance.keys():
          new_shape = curr_importance[name].data.shape
          if name not in self.importance:
              self.importance[name] = ParamData(
                  name,
                  curr_importance[name].shape,
                  device=curr_importance[name].device,
                  init_tensor=curr_importance[name].data.clone(),
              )
          else:
              self.importance[name].data = (
                  self.alpha * self.importance[name].expand(new_shape)
                  + (1 - self.alpha) * curr_importance[name].data
              )
  
file_path: avalanche/avalanche/training/plugins/mas.py
imports: from tqdm.auto import tqdm
  from typing import Dict, Union
  from torch.utils.data import DataLoader
  import torch
  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 4 for calling the MASPlugin obj's underlying member method code with example usage: obj.after_training_exp(strategy) without return types