code: def test_load_state_from_peers():
      num_calls = 0
      super_metadata = dict(x=123)
      super_tensors = (torch.randn(3), torch.randint(0, 5, (3,)))
  
      class TestAverager(DecentralizedAverager):
          def get_current_state(self):
              """
              Get current state and send it to a peer. executed in the host process. Meant to be overridden.
              :returns: a tuple of (serializable_small_metadata, sequence of torch tensors)
              """
              nonlocal num_calls, super_metadata, super_tensors
              num_calls += 1
              return super_metadata, super_tensors
  
      dht_instances = launch_dht_instances(2)
      averager1 = TestAverager(
          [torch.randn(3), torch.rand(5)],
          dht=dht_instances[0],
          start=True,
          prefix="demo-run",
          target_group_size=2,
      )
  
      averager2 = TestAverager(
          [torch.randn(3), torch.rand(5)],
          dht=dht_instances[1],
          start=True,
          prefix="demo-run",
          target_group_size=2,
      )
  
      time.sleep(0.5)
  
      assert num_calls == 0
      got_metadata, got_tensors = averager2.load_state_from_peers()
      assert num_calls == 1
      assert got_metadata == super_metadata
      assert all(map(torch.allclose, got_tensors, super_tensors))
  
      super_metadata["y"] = 123
      super_tensors[1][2] = 9
      assert num_calls == 1
      assert got_metadata != super_metadata
      assert not all(map(torch.allclose, got_tensors, super_tensors))
      got_metadata, got_tensors = averager2.load_state_from_peers()
      assert num_calls == 2
      assert got_metadata == super_metadata
      assert all(map(torch.allclose, got_tensors, super_tensors))
  
      averager1.allow_state_sharing = False
      assert averager2.load_state_from_peers() is None
  
      averager1.allow_state_sharing = True
      time.sleep(0.5)
      got_metadata, got_tensors = averager2.load_state_from_peers()
      assert num_calls == 3
      assert got_metadata == super_metadata
  
      for instance in [averager1, averager2] + dht_instances:
          instance.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 13 for calling a global function with example usage: test_load_state_from_peers() and returns: super_metadata,  super_tensors