code: def _load_from_socket(
      port: Optional[Union[str, int]],
      auth_secret: str,
      function: int,
      all_gather_message: Optional[str] = None,
  ) -> List[str]:
      """
      Load data from a given socket, this is a blocking method thus only return when the socket
      connection has been closed.
      """
      (sockfile, sock) = local_connect_and_auth(port, auth_secret)
  
      # The call may block forever, so no timeout
      sock.settimeout(None)
  
      if function == BARRIER_FUNCTION:
          # Make a barrier() function call.
          write_int(function, sockfile)
      elif function == ALL_GATHER_FUNCTION:
          # Make a all_gather() function call.
          write_int(function, sockfile)
          write_with_length(
              cast(str, all_gather_message).encode("utf-8"), sockfile
          )
      else:
          raise ValueError("Unrecognized function type")
      sockfile.flush()
  
      # Collect result.
      len = read_int(sockfile)
      res = []
      for i in range(len):
          res.append(UTF8Deserializer().loads(sockfile))
  
      # Release resources.
      sockfile.close()
      sock.close()
  
      return res
  
imports: from typing import ClassVar, Type, Dict, List, Optional, Union, cast
  from pyspark.java_gateway import local_connect_and_auth
  from pyspark.resource import ResourceInformation
  from pyspark.serializers import read_int, write_int, write_with_length, UTF8Deserializer
  from pyspark.errors import PySparkRuntimeError
label_desc: Use image node_id 1 for calling a global function with example usage: _load_from_socket(port, auth_secret, function, all_gather_message) and returns: res