class_docstr: Add AR and TAR regularization
class_docstr_tok: ["Add","AR","and","TAR","regularization"]
code: def after_loss(self):
      if not self.training:
          return
      if self.alpha:
          self.learn.loss_grad += (
              self.alpha * self.rnn.out.float().pow(2).mean()
          )
      if self.beta:
          h = self.rnn.raw_out
          if len(h) > 1:
              self.learn.loss_grad += (
                  self.beta
                  * (h[:, 1:] - h[:, :-1]).float().pow(2).mean()
              )
  
file_path: fastai/fastai/callback/rnn.py
imports: from __future__ import annotations
  from ..basics import *
label_desc: Use image node_id 2 for calling the RNNRegularizer obj's underlying member method code with example usage: obj.after_loss() without return types