code: def check_all_hosts_ssh_successful(host_addresses, ssh_port=None):
      """Checks if ssh can successfully be performed to all the hosts.
  
      Args:
        host_addresses: list of addresses to ssh into. for example,
          ['worker-0','worker-1']
          ['10.11.11.11', '10.11.11.12']
        ssh_port: A int for ssh port number.
  
      Returns:
        True if all ssh was successful into all the addresses.
      """
      if ssh_port:
          ssh_port_arg = "-p {ssh_port}".format(ssh_port=ssh_port)
      else:
          ssh_port_arg = ""
  
      ssh_command_format = (
          "ssh -o StrictHostKeyChecking=no {host} {ssh_port_arg} date"
      )
  
      args_list = [
          ssh_command_format.format(
              host=host_address, ssh_port_arg=ssh_port_arg
          )
          for host_address in host_addresses
      ]
      ssh_exit_codes = execute_function_multithreaded(
          exec_command, args_list
      )
  
      ssh_successful_to_all_hosts = True
      for index, ssh_status in ssh_exit_codes.items():
          exit_code, output_msg = ssh_status[0], ssh_status[1]
          if exit_code != 0:
              print(
                  "ssh not successful for host {host}:\n{msg_output}".format(
                      host=host_addresses[index], msg_output=output_msg
                  )
              )
  
              ssh_successful_to_all_hosts = False
      if not ssh_successful_to_all_hosts:
          exit(1)
      return True
  
file_path: bluefog/bluefog/run/network_util.py
imports: import concurrent.futures
  import io
  import os
  import re
  import socket
  import psutil
  from bluefog.run.horovodrun.common.util import safe_shell_exec
label_desc: Use image node_id 8 for calling a global function with example usage: check_all_hosts_ssh_successful(host_addresses, ssh_port) and returns: True