code: def launch_swarm_in_separate_processes(
      n_peers: int, n_sequential_peers: int, **kwargs
  ) -> Tuple[
      List[mp.Process], Dict[PeerID, DHTID], List[List[Multiaddr]]
  ]:
      assert (
          n_sequential_peers < n_peers
      ), "Parameters imply that first n_sequential_peers of n_peers will be run sequentially"
  
      processes = []
      dht = {}
      swarm_maddrs = []
  
      info_queue = mp.Queue()
      info_lock = mp.RLock()
  
      for _ in range(n_sequential_peers):
          initial_peers = (
              random.choice(swarm_maddrs) if swarm_maddrs else []
          )
  
          proc = mp.Process(
              target=run_node,
              args=(initial_peers, info_queue),
              kwargs=kwargs,
              daemon=True,
          )
          proc.start()
          processes.append(proc)
  
          node_id, peer_id, peer_maddrs = info_queue.get()
          dht[peer_id] = node_id
          swarm_maddrs.append(peer_maddrs)
  
      def collect_info():
          while True:
              node_id, peer_id, peer_maddrs = info_queue.get()
              with info_lock:
                  dht[peer_id] = node_id
                  swarm_maddrs.append(peer_maddrs)
  
                  if len(dht) == n_peers:
                      break
  
      collect_thread = threading.Thread(target=collect_info)
      collect_thread.start()
  
      for _ in range(n_peers - n_sequential_peers):
          with info_lock:
              initial_peers = random.choice(swarm_maddrs)
  
          proc = mp.Process(
              target=run_node,
              args=(initial_peers, info_queue),
              kwargs=kwargs,
              daemon=True,
          )
          proc.start()
          processes.append(proc)
  
      collect_thread.join()
  
      return processes, dht, swarm_maddrs
  
file_path: hivemind/tests/test_utils/dht_swarms.py
imports: import asyncio
  import multiprocessing
  import random
  import signal
  import threading
  from typing import Dict, List, Tuple
  from multiaddr import Multiaddr
  from hivemind.dht import DHT
  from hivemind.dht.node import DHTID, DHTNode
  from hivemind.p2p import PeerID
label_desc: Use image node_id 2 for calling a global function with example usage: launch_swarm_in_separate_processes(n_peers, n_sequential_peers) and returns: processes,  dht,  swarm_maddrs