docstr: Updates running moments from batch's moments computed across ranks
docstr_tok: ["Updates","running","moments","from","batch","'s","moments","computed","across","ranks"]
code: def update(self, xs: torch.Tensor) -> Tuple[float, float]:
      """
      Updates running moments from batch's moments computed across ranks
      """
      if self.accelerator.use_distributed:
          xs_mean, xs_var, xs_count = get_global_statistics(
              self.accelerator, xs
          )
      else:
          xs_count = xs.numel()
          xs_var, xs_mean = torch.var_mean(xs, unbiased=False)
      xs_mean, xs_var = xs_mean.float(), xs_var.float()
  
      delta = xs_mean - self.mean
      tot_count = self.count + xs_count
  
      new_sum = xs_var * xs_count
      # correct old_sum deviation accounting for the new mean
      old_sum = (
          self.var * self.count
          + delta**2 * self.count * xs_count / tot_count
      )
      tot_sum = old_sum + new_sum
  
      self.mean += delta * xs_count / tot_count
      self.var = tot_sum / tot_count
      self.std = (self.var * tot_count / (tot_count - 1)).float().sqrt()
      self.count = tot_count
  
      return (
          xs_mean.item(),
          (xs_var * xs_count / (xs_count - 1)).float().sqrt().item(),
      )
  
imports: import random
  import warnings
  from collections import deque
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch.nn.utils.rnn import pad_sequence
  from torch.utils.data import IterableDataset
  from transformers import DataCollatorForLanguageModeling, PreTrainedTokenizerBase
  from ..import_utils import is_unsloth_available
label_desc: Use image node_id 2 for calling the RunningMoments obj's underlying member method code with example usage: obj.update(xs) and returns: xs_mean,  unknown