code: def get_hosts_arg_and_hostnames(args):
      # if hosts are not specified, either parse from hostfile, or default as
      # localhost
      if not args.hosts:
          if args.hostfile:
              args.hosts = _parse_host_files(args.hostfile)
          else:
              # Set hosts to localhost if not specified
              args.hosts = "localhost:{np}".format(np=args.np)
  
      all_host_names = []
      host_list = args.hosts.split(",")
      all_host_names = []
      pattern = re.compile(r"^[\w.-]+:\d+$")
      for host in host_list:
          if not pattern.match(host.strip()):
              raise ValueError(
                  "Invalid host input, please make sure it has "
                  "format as : worker-0:2,worker-1:2."
              )
          all_host_names.append(host.strip().split(":")[0])
      hosts_arg = "-H {hosts}".format(hosts=args.hosts)
      return hosts_arg, all_host_names
  
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 3 for calling a global function with example usage: get_hosts_arg_and_hostnames(args) and returns: hosts_arg,  all_host_names