class_docstr: A BatchNorm layer tracks multiple micro-batches to update running statistics per mini-batch.
class_docstr_tok: ["A","BatchNorm","layer","tracks","multiple","micro-batches","to","update","running","statistics","per","mini-batch","."]
docstr: Update the running statistics of a mini-batch.
docstr_tok: ["Update","the","running","statistics","of","a","mini-batch","."]
code: def _commit(self) -> None:
      """Update the running statistics of a mini-batch."""
      exponential_average_factor = 0.0
      self.num_batches_tracked += 1
      if self.momentum is None:  # use cumulative moving average
          exponential_average_factor = 1.0 / float(
              self.num_batches_tracked
          )
      else:  # use exponential moving average
          exponential_average_factor = self.momentum
  
      mean = self.sum / self.counter
      var = self.sum_squares / self.counter - mean**2
  
      # Calculate the exponential moving average here.
      m = exponential_average_factor
  
      self.running_mean *= 1 - m
      self.running_mean += mean * m
  
      self.running_var *= 1 - m
      self.running_var += var * m
  
      self.sum.zero_()
      self.sum_squares.zero_()
      self.counter = 0
      self.tracked = 0
  
file_path: pytorch/torch/distributed/pipeline/sync/batchnorm.py
imports: from typing import TypeVar, cast
  import torch
  from torch import Tensor, nn
  from torch.nn.functional import batch_norm
  from torch.nn.modules.batchnorm import _BatchNorm
  from .checkpoint import is_recomputing
label_desc: Use image node_id 4 for calling the DeferredBatchNorm obj's underlying member method code with example usage: obj._commit() without return types