class_docstr: Accumulate gradients before updating weights
class_docstr_tok: ["Accumulate","gradients","before","updating","weights"]
docstr: Skip weight update if we have not seen enough items
docstr_tok: ["Skip","weight","update","if","we","have","not","seen","enough","items"]
code: def before_step(self):
      "Skip weight update if we have not seen enough items"
      self.learn.loss_grad *= self.n_acc / find_bs(
          self.learn.yb
      )  # log correct loss
      self.count += find_bs(self.learn.yb)
      if self.count < self.n_acc:
          raise CancelBatchException()  # skip step/zero_grad
      else:
          self.count = 0
  
imports: from __future__ import annotations
  from ..basics import *
  from .progress import *
  from .fp16 import *
label_desc: Use image node_id 4 for calling the GradientAccumulation obj's underlying member method code with example usage: obj.before_step() without return types