docstr: Implementation of Look-ahead MAML (LaMAML) algorithm in Avalanche
      using Higher library for applying fast updates.
  
  :param model: PyTorch model.
  :param optimizer: PyTorch optimizer.
  :param criterion: loss function.
  :param mem_size: maximum size of the buffer.
  :param batch_size_mem: number of samples to retrieve from buffer
      for each sample.
  :param n_inner_steps: number of inner updates per sample.
  :param beta: coefficient for within-batch Reptile update.
  :param gamma: coefficient for within-task Reptile update.
docstr_tok: ["Implementation","of","Look-ahead","MAML","(","LaMAML",")","algorithm","in","Avalanche","using","Higher","library","for","applying","fast","updates",".",":","param","model",":","PyTorch","model",".",":","param","optimizer",":","PyTorch","optimizer",".",":","param","criterion",":","loss","function",".",":","param","mem_size",":","maximum","size","of","the","buffer",".",":","param","batch_size_mem",":","number","of","samples","to","retrieve","from","buffer","for","each","sample",".",":","param","n_inner_steps",":","number","of","inner","updates","per","sample",".",":","param","beta",":","coefficient","for","within-batch","Reptile","update",".",":","param","gamma",":","coefficient","for","within-task","Reptile","update","."]
code: def __init__(
      self,
      model: Module,
      optimizer: Optimizer,
      criterion=CrossEntropyLoss(),
      mem_size=200,
      batch_size_mem=10,
      n_inner_steps=5,
      beta=0.1,
      gamma=0.1,
      train_mb_size: int = 1,
      train_epochs: int = 1,
      eval_mb_size: int = 1,
      device: Union[str, torch.device] = "cpu",
      plugins: Optional[Sequence["SupervisedPlugin"]] = None,
      evaluator: Union[
          EvaluationPlugin, Callable[[], EvaluationPlugin]
      ] = default_evaluator,
      eval_every=-1,
      peval_mode="epoch",
  ):
      """Implementation of Look-ahead MAML (LaMAML) algorithm in Avalanche
          using Higher library for applying fast updates.
  
      :param model: PyTorch model.
      :param optimizer: PyTorch optimizer.
      :param criterion: loss function.
      :param mem_size: maximum size of the buffer.
      :param batch_size_mem: number of samples to retrieve from buffer
          for each sample.
      :param n_inner_steps: number of inner updates per sample.
      :param beta: coefficient for within-batch Reptile update.
      :param gamma: coefficient for within-task Reptile update.
  
      """
      super().__init__(
          model,
          optimizer,
          criterion,
          train_mb_size,
          train_epochs,
          eval_mb_size,
          device,
          plugins,
          evaluator,
          eval_every,
          peval_mode,
      )
  
      self.buffer = MERBuffer(
          mem_size=mem_size,
          batch_size_mem=batch_size_mem,
          device=self.device,
      )
      self.n_inner_steps = n_inner_steps
      self.beta = beta
      self.gamma = gamma
  
imports: from copy import deepcopy
  from typing import Callable, Optional, Sequence, Union
  import torch
  import torch.nn.functional
  from torch.nn import CrossEntropyLoss, Module
  from torch.optim import Optimizer
  from avalanche.models.utils import avalanche_forward
  from avalanche.training.plugins import EvaluationPlugin, SupervisedPlugin
  from avalanche.training.plugins.evaluation import default_evaluator
  from avalanche.training.storage_policy import ReservoirSamplingBuffer
  from avalanche.training.templates import SupervisedMetaLearningTemplate
label_desc: Use image node_id 1 to create a new MER object from inherited base classes: SupervisedMetaLearningTemplate with example: obj = MER(model, optimizer, criterion, mem_size, batch_size_mem, n_inner_steps, beta, gamma, train_mb_size, train_epochs, eval_mb_size, device, plugins, evaluator, eval_every, peval_mode)