code: def update(self):
      if self.group is None:
          self.group = moolib.Group(self.rpc, "test group")
          self.group.set_timeout(1)
          self.group.set_sort_order(self.index)
      elif random.random() < 0.5 or True:
          updated = self.group.update()
  
          if updated:
              print(
                  "group '%s', sync id %#x, members %s"
                  % (
                      self.group.name(),
                      self.group.sync_id(),
                      self.group.members(),
                  )
              )
  
      if self.group.active():
          if self.reduce is None:
              self.start_reduce()
          else:
              result = None
  
              global current_reduce_size
              global current_reduce_done
              global current_reduce_sum
  
              try:
                  if self.reduce.done():
                      # although the result is available in self.tensor,
                      # calling .result() here is necessary to raise any errors
                      result = self.reduce.result()
              except RuntimeError as e:
                  current_reduce_size = 0
                  current_reduce_done = 0
                  print(e)
                  self.reduce = None
  
              if result is not None:
                  self.sum = result.sum().item()
                  print("reduced to sum ", self.sum)
                  self.reduce = None
                  if current_reduce_size == current_reduce_done:
                      current_reduce_done = 1
                      current_reduce_size = len(self.group.members())
                      current_reduce_sum = self.sum
                      print(
                          "New reduction of size %d"
                          % current_reduce_size
                      )
                  else:
                      current_reduce_done += 1
                      if abs(self.sum - current_reduce_sum) > 0.01:
                          raise RuntimeError(
                              "Reduce sum mismatch, got %g, expected %g"
                              % (self.sum, current_reduce_sum)
                          )
                      print(
                          "Reduce %d/%d done"
                          % (current_reduce_done, current_reduce_size)
                      )
  
file_path: moolib/test/test_reduce.py
imports: import moolib
  import time
  import torch
  import random
label_desc: Use image node_id 2 for calling the Client obj's underlying member method code with example usage: obj.update() without return types