code: def _get_named_client_logger(
      name: str,
      host: str = "localhost",
      port: int = logging.handlers.DEFAULT_TCP_LOGGING_PORT,
  ) -> logging.Logger:
      """
      When working with a logging server, clients are expected to create a logger using
      this method. For example, the automl object will create a master that awaits
      for records sent through tcp to localhost.
  
      Ensemble builder will then instantiate a logger object that will submit records
      via a socket handler to the server.
  
      We do not need to use any format as the server will render the msg as it
      needs to.
  
      Parameters
      ----------
          name: (str)
              the name of the logger, used to tag the messages in the main log
          host: (str)
              Address of where the server is gonna look for messages
          port: (str)
              Port used to communicate with the server
  
      Returns
      -------
          local_loger: a logger object that has a socket handler
      """
      # Setup the logger configuration
      # We add client not only to identify that this is the client
      # communication part of the logger, but to make sure we have
      # a new singleton with the desired socket handlers
      local_logger = _create_logger("Client-" + name)
      local_logger.propagate = False
      local_logger.setLevel(logging.DEBUG)
  
      try:
          # Ignore mypy logging.handlers.SocketHandler has no attribute port
          # This is not the case clearly, yet MyPy assumes this is not the case
          # Even when using direct casting or getattr
          ports = [
              getattr(handler, "port", None)
              for handler in local_logger.handlers
          ]  # type: ignore[attr-defined]
      except AttributeError:
          # We do not want to log twice but adding multiple times the same
          # handler. So we check to what ports we communicate to
          # We can prevent errors with streamers not having a port with this try
          # block -- but it is a scenario that is unlikely to happen
          ports = []
  
      if port not in ports:
          socketHandler = logging.handlers.SocketHandler(host, port)
          local_logger.addHandler(socketHandler)
  
      return local_logger
  
imports: from typing import Any, Dict, Iterator, Optional, TextIO, Type, cast
  import logging
  import logging.config
  import logging.handlers
  import multiprocessing
  import os
  import pickle
  import random
  import select
  import socketserver
  import struct
  import threading
  import warnings
  from contextlib import contextmanager
  import yaml
label_desc: Use image node_id 5 for calling a global function with example usage: _get_named_client_logger(name, host, port) and returns: local_logger