code: def background_server(
      *args, shutdown_timeout=5, **kwargs
  ) -> PeerInfo:
      """A context manager that creates server in a background , awaits .ready on entry and shuts down on exit"""
      pipe, runners_pipe = mp.Pipe(duplex=True)
      runner = mp.Process(
          target=_server_runner,
          args=(runners_pipe, *args),
          kwargs=kwargs,
      )
      try:
          runner.start()
          # once the server is ready, runner will send us
          # either (False, exception) or (True, PeerInfo(dht_peer_id, dht_maddrs))
          start_ok, data = pipe.recv()
          if start_ok:
              yield data
              pipe.send(
                  "SHUTDOWN"
              )  # on exit from context, send shutdown signal
          else:
              raise RuntimeError(f"Server failed to start: {data}")
      finally:
          runner.join(timeout=shutdown_timeout)
          if runner.is_alive():
              logger.info(
                  "Server failed to shutdown gracefully, terminating it the hard way..."
              )
              runner.kill()
              logger.info("Server terminated")
  
imports: from __future__ import annotations
  import multiprocessing
  import random
  import threading
  from contextlib import contextmanager
  from functools import partial
  from pathlib import Path
  from typing import Dict, List, Optional
  import torch
  from hivemind.dht import DHT
  from hivemind.moe.expert_uid import UID_DELIMITER
  from hivemind.moe.server.checkpoints import CheckpointSaver, is_directory, load_experts
  from hivemind.moe.server.connection_handler import ConnectionHandler
  from hivemind.moe.server.dht_handler import DHTHandlerThread, get_experts
  from hivemind.moe.server.layers import add_custom_models_from_file, name_to_block, name_to_input, schedule_name_to_scheduler
  from hivemind.moe.server.layers.optim import ClippingWrapper
  from hivemind.moe.server.module_backend import ModuleBackend
  from hivemind.moe.server.runtime import Runtime
  from hivemind.p2p import PeerInfo
  from hivemind.proto.runtime_pb2 import CompressionType
  from hivemind.utils.logging import get_logger
  from hivemind.utils.tensor_descr import DUMMY_BATCH_SIZE, BatchTensorDescriptor
label_desc: Use image node_id 1 for calling a global function with example usage: background_server() without return types