class_docstr: This class mirrors deepspeed functionality. Not all changes are implemented in this version.
  
  See TorchEngineFull for more modifications.
class_docstr_tok: ["This","class","mirrors","deepspeed","functionality",".","Not","all","changes","are","implemented","in","this","version",".","See","TorchEngineFull","for","more","modifications","."]
code: def moving_average_computation(self):
      if self.weight_averaging_frequency > 0:
          if (self.steps % self.weight_averaging_frequency) == 0:
              params = [
                  p.detach().cpu() for p in self.model.parameters()
              ]
              buffers = [b.detach().cpu() for b in self.model.buffers()]
              if self.weight_averaging.type == "EMA":
                  update_ema(
                      params,
                      self.param_store,
                      buffers,
                      self.buffer_store,
                      momentum=self.weight_averaging.momentum,
                  )
              else:  # latest weight averaging
                  (
                      self.param_store,
                      self.buffer_store,
                  ) = updated_latest_weight_average(
                      params,
                      buffers,
                      self.store,
                      last_k=self.weight_averaging.last_k,
                  )
  
imports: import torch
  import torch._inductor.utils
  import os
  import json
  from omegaconf import OmegaConf
  from functools import partial
  from contextlib import nullcontext
  import time
  import logging
  import transformers
  from safetensors.torch import load_file, save_file
  from transformers.utils.generic import working_or_temp_dir
  from torch.distributed.optim import ZeroRedundancyOptimizer
  from .utils import group_parameters, prepare_pretraining_dataloader, update_ema, updated_latest_weight_average
  from .optimizers.schedulers import get_schedule_fn
  from .optimizers import Adahessian, AdamWScale, Shampoo, LARS, SAM, ProgressiveBatching, AGD, Sophia
  import warnings
label_desc: Use image node_id 7 for calling the TorchEngineFull obj's underlying member method code with example usage: obj.moving_average_computation() without return types