code: def update_value(self, name, value, weighted_avg=False):
      if name not in self.avg_values:
          # add value if not exist before
          self.add_value(name, init_val=value)
      else:
          # else update existing value
          if weighted_avg:
              self.avg_values[name] = (
                  0.99 * self.avg_values[name] + 0.01 * value
              )
              self.iters[name] += 1
          else:
              self.avg_values[name] = (
                  self.avg_values[name] * self.iters[name] + value
              )
              self.iters[name] += 1
              self.avg_values[name] /= self.iters[name]
  
imports: import datetime
  import glob
  import os
  import shutil
  import subprocess
  import sys
  from pathlib import Path
  import torch
label_desc: Use image node_id 5 for calling the KeepAverage obj's underlying member method code with example usage: obj.update_value(name, value, weighted_avg) without return types