code: def test_allgather(n_averagers=8, target_group_size=4):
      dht_instances = launch_dht_instances(n_averagers)
      averagers = [
          DecentralizedAverager(
              [torch.ones(1)],
              dht=dht,
              target_group_size=target_group_size,
              min_matchmaking_time=15,
              prefix="mygroup",
              initial_group_bits="000",
              start=True,
          )
          for dht in dht_instances
      ]
  
      futures = []
      for i, averager in enumerate(averagers):
          futures.append(
              averager.step(
                  wait=False, gather=dict(batch_size=123 + i, foo="bar")
              )
          )
  
      reference_metadata = {
          averager.peer_id: dict(batch_size=123 + i, foo="bar")
          for i, averager in enumerate(averagers)
      }
      for future in futures:
          gathered = future.result()
          assert len(gathered) == target_group_size
          for peer_id in gathered:
              assert gathered[peer_id] == reference_metadata[peer_id]
  
      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 7 for calling a global function with example usage: test_allgather(n_averagers, target_group_size) without return types