code: def _test_allreduce_once(n_clients, n_aux):
      n_peers = 4
      modes = (
          [AveragingMode.CLIENT] * n_clients
          + [AveragingMode.AUX] * n_aux
          + [AveragingMode.NODE] * (n_peers - n_clients - n_aux)
      )
      random.shuffle(modes)
  
      tensors1 = [torch.randn(123), torch.zeros(3)]
      tensors2 = [torch.rand(123), torch.ones(3)]
      tensors3 = [-torch.rand(123), torch.arange(3).to(torch.float32)]
      tensors4 = [
          torch.randn(123) ** 3,
          torch.arange(3).to(torch.float32) / 2,
      ]
      peer_tensors = [tensors1, tensors2, tensors3, tensors4]
  
      reference = [
          sum(
              tensors[i]
              for tensors, mode in zip(peer_tensors, modes)
              if mode != AveragingMode.AUX
          )
          / max(1, n_peers - n_aux)
          for i in range(len(tensors1))
      ]
  
      dht_instances = launch_dht_instances(len(peer_tensors))
      averagers = [
          DecentralizedAverager(
              tensors,
              dht=dht,
              target_group_size=4,
              min_matchmaking_time=15,
              prefix="mygroup",
              client_mode=mode == AveragingMode.CLIENT,
              auxiliary=mode == AveragingMode.AUX,
              start=True,
          )
          for tensors, dht, mode in zip(
              peer_tensors, dht_instances, modes
          )
      ]
  
      futures = []
      for averager in averagers:
          futures.append(averager.step(wait=False))
      for future in futures:
          result = future.result()
          for averager in averagers:
              assert averager.peer_id in result
  
      for averager in averagers:
          if averager.mode != AveragingMode.AUX:
              with averager.get_tensors() as averaged_tensors:
                  for ref, our in zip(reference, averaged_tensors):
                      assert torch.allclose(ref, our, atol=1e-6)
  
      for process in averagers + dht_instances:
          process.shutdown()
  
imports: import random
  import time
  import numpy
  import pytest
  import torch
  import hivemind
  from hivemind.averaging import DecentralizedAverager
  from hivemind.averaging.allreduce import AveragingMode
  from hivemind.averaging.control import AveragingStage
  from hivemind.averaging.key_manager import GroupKeyManager
  from hivemind.averaging.load_balancing import load_balance_peers
  from hivemind.averaging.partition import AllreduceException
  from hivemind.p2p import PeerID
  from test_utils.dht_swarms import launch_dht_instances
label_desc: Use image node_id 1 for calling a global function with example usage: _test_allreduce_once(n_clients, n_aux) without return types