code: def connect_to_server(
      ip_config,
      num_servers,
      max_queue_size=MAX_QUEUE_SIZE,
      group_id=0,
  ):
      """Connect this client to server.
  
      Parameters
      ----------
      ip_config : str
          Path of server IP configuration file.
      num_servers : int
          server count on each machine.
      max_queue_size : int
          Maximal size (bytes) of client queue buffer (~20 GB on default).
          Note that the 20 GB is just an upper-bound and DGL uses zero-copy and
          it will not allocate 20GB memory at once.
      group_id : int
          Indicates which group this client belongs to. Clients that are
          booted together in each launch are gathered as a group and should
          have same unique group_id.
  
      Raises
      ------
      ConnectionError : If anything wrong with the connection.
      """
      assert num_servers > 0, (
          "num_servers (%d) must be a positive number." % num_servers
      )
      assert max_queue_size > 0, (
          "queue_size (%d) cannot be a negative number."
          % max_queue_size
      )
      # Register some basic service
      rpc.register_service(
          rpc.CLIENT_REGISTER,
          rpc.ClientRegisterRequest,
          rpc.ClientRegisterResponse,
      )
      rpc.register_service(
          rpc.SHUT_DOWN_SERVER, rpc.ShutDownRequest, None
      )
      rpc.register_service(
          rpc.GET_NUM_CLIENT,
          rpc.GetNumberClientsRequest,
          rpc.GetNumberClientsResponse,
      )
      rpc.register_service(
          rpc.CLIENT_BARRIER,
          rpc.ClientBarrierRequest,
          rpc.ClientBarrierResponse,
      )
      rpc.register_sig_handler()
      server_namebook = rpc.read_ip_config(ip_config, num_servers)
      num_servers = len(server_namebook)
      rpc.set_num_server(num_servers)
      # group_count means how many servers
      # (main_server + bakcup_server) in total inside a machine.
      group_count = []
      max_machine_id = 0
      for server_info in server_namebook.values():
          group_count.append(server_info[3])
          if server_info[0] > max_machine_id:
              max_machine_id = server_info[0]
      rpc.set_num_server_per_machine(group_count[0])
      num_machines = max_machine_id + 1
      rpc.set_num_machines(num_machines)
      machine_id = get_local_machine_id(server_namebook)
      rpc.set_machine_id(machine_id)
      rpc.set_group_id(group_id)
      rpc.create_sender(max_queue_size)
      rpc.create_receiver(max_queue_size)
      # Get connected with all server nodes
      max_try_times = int(
          os.environ.get("DGL_DIST_MAX_TRY_TIMES", 1024)
      )
      for server_id, addr in server_namebook.items():
          server_ip = addr[1]
          server_port = addr[2]
          try_times = 0
          while not rpc.connect_receiver(
              server_ip, server_port, server_id
          ):
              try_times += 1
              if try_times % 200 == 0:
                  print(
                      "Client is trying to connect server receiver: {}:{}".format(
                          server_ip, server_port
                      )
                  )
              if try_times >= max_try_times:
                  raise rpc.DistConnectError(
                      max_try_times, server_ip, server_port
                  )
              time.sleep(3)
      if not rpc.connect_receiver_finalize(max_try_times):
          raise rpc.DistConnectError(max_try_times)
      # Get local usable IP address and port
      ip_addr = get_local_usable_addr(server_ip)
      client_ip, client_port = ip_addr.split(":")
      # Register client on server
      register_req = rpc.ClientRegisterRequest(ip_addr)
      for server_id in range(num_servers):
          rpc.send_request(server_id, register_req)
      # wait server connect back
      rpc.wait_for_senders(client_ip, client_port, num_servers)
      print(
          "Client [{}] waits on {}:{}".format(
              os.getpid(), client_ip, client_port
          )
      )
      # recv client ID from server
      res = rpc.recv_response()
      rpc.set_rank(res.client_id)
      print(
          "Machine (%d) group (%d) client (%d) connect to server successfuly!"
          % (machine_id, group_id, rpc.get_rank())
      )
      # get total number of client
      get_client_num_req = rpc.GetNumberClientsRequest(rpc.get_rank())
      rpc.send_request(0, get_client_num_req)
      res = rpc.recv_response()
      rpc.set_num_client(res.num_client)
      from .dist_context import exit_client, set_initialized
  
      atexit.register(exit_client)
      set_initialized(True)
  
file_path: dgl/python/dgl/distributed/rpc_client.py
imports: import atexit
  import logging
  import os
  import socket
  import time
  from .None import rpc
  from .constants import MAX_QUEUE_SIZE
label_desc: Use image node_id 4 for calling a global function with example usage: connect_to_server(ip_config, num_servers, max_queue_size, group_id) without return types