class_docstr: From Scratch Training Plugin.
  
  This plugin resets the strategy's model weights and optimizer state after
  each experience. It expects the strategy to have a single model and
  optimizer. It can be used with the Naive strategy to produce
  "from-scratch training" baselines.
docstr: Called after `train_exp` by the `BaseTemplate`.
docstr_tok: ["Called","after","`","train_exp","`","by","the","`","BaseTemplate","`","."]
code: def before_training_exp(
      self, strategy: BaseSGDTemplate, *args, **kwargs
  ):
      """Called after `train_exp` by the `BaseTemplate`."""
      # Copy the initial weights to the model
      init_weights = self.initial_weights
      assert init_weights is not None
  
      for n, p in strategy.model.named_parameters():
          if n in init_weights.keys():
              if p.data.shape == init_weights[n].data.shape:
                  p.data.copy_(init_weights[n].data)
  
      # Update the initial weights (in case new parameters are added)
      self.initial_weights = deepcopy(strategy.model.state_dict())
  
      # Reset the optimizer state
      if self.reset_optimizer:
          reset_optimizer(strategy.optimizer, strategy.model)
  
file_path: avalanche/avalanche/training/plugins/from_scratch_training.py
imports: from copy import deepcopy
  from typing import Dict, Optional
  from torch import Tensor
  from avalanche.core import BaseSGDPlugin
  from avalanche.training.templates import BaseSGDTemplate
  from avalanche.models.dynamic_optimizers import reset_optimizer
label_desc: Use image node_id 3 for calling the FromScratchTrainingPlugin obj's underlying member method code with example usage: obj.before_training_exp(strategy) without return types