docstr: Updates BatchNorm running_mean, running_var buffers in the model.
  
  It performs one pass over data in `loader` to estimate the activation
  statistics for BatchNorm layers in the model.
  
  Args:
      loader (torch.utils.data.DataLoader): dataset loader to compute the
          activation statistics on. Each data batch should be either a
          tensor, or a list/tuple whose first element is a tensor
          containing data.
  
      model (torch.nn.Module): model for which we seek to update BatchNorm
          statistics.
  
      device (torch.device, optional): If set, data will be trasferred to
          :attr:`device` before being passed into :attr:`model`.
docstr_tok: ["Updates","BatchNorm","running_mean",",","running_var","buffers","in","the","model",".","It","performs","one","pass","over","data","in","`","loader","`","to","estimate","the","activation","statistics","for","BatchNorm","layers","in","the","model",".","Args",":","loader","(","torch.utils.data.DataLoader",")",":","dataset","loader","to","compute","the","activation","statistics","on",".","Each","data","batch","should","be","either","a","tensor",",","or","a","list\/tuple","whose","first","element","is","a","tensor","containing","data",".","model","(","torch.nn.Module",")",":","model","for","which","we","seek","to","update","BatchNorm","statistics",".","device","(","torch.device",",","optional",")",":","If","set",",","data","will","be","trasferred","to",":","attr",":","`","device","`","before","being","passed","into",":","attr",":","`","model","`","."]
code: def bn_update(loader, model, device=None):
      r"""Updates BatchNorm running_mean, running_var buffers in the model.
  
      It performs one pass over data in `loader` to estimate the activation
      statistics for BatchNorm layers in the model.
  
      Args:
          loader (torch.utils.data.DataLoader): dataset loader to compute the
              activation statistics on. Each data batch should be either a
              tensor, or a list/tuple whose first element is a tensor
              containing data.
  
          model (torch.nn.Module): model for which we seek to update BatchNorm
              statistics.
  
          device (torch.device, optional): If set, data will be trasferred to
              :attr:`device` before being passed into :attr:`model`.
      """
      if not _check_bn(model):
          return
      was_training = model.training
      model.train()
      momenta = {}
      model.apply(_reset_bn)
      model.apply(lambda module: _get_momenta(module, momenta))
      n = 0
      for input in loader:
          if isinstance(input, (list, tuple)):
              input = input[0]
          b = input.size(0)
  
          momentum = b / float(n + b)
          for module in momenta.keys():
              module.momentum = momentum
  
          if device is not None:
              input = input.to(device)
  
          model(input)
          n += b
  
      model.apply(lambda module: _set_momenta(module, momenta))
      model.train(was_training)
  
imports: import warnings
  from collections import defaultdict
  from typing import Optional, Union
  import torch
  from pytext.config.component import create_optimizer
  from pytext.optimizer.lamb import Lamb
  from pytext.optimizer.madgrad import MADGRAD
  from pytext.optimizer.optimizers import Adagrad, Adam, AdamW, Optimizer, SGD
  from pytext.optimizer.radam import RAdam
  from torch.optim import Optimizer
label_desc: Use image node_id 11 for calling the StochasticWeightAveraging obj's underlying member method code with example usage: obj.bn_update(loader, model, device) without return types