code: def parse_hosts_and_slots(hosts):
      host_names = []
      host_to_slots = {}
  
      host_list = hosts.split(",")
      pattern = re.compile(r"^[\w.-]+:[0-9]+$")
      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."
              )
          hostname, slots = host.strip().split(":")
          host_names.append(hostname)
          host_to_slots[hostname] = int(slots)
      return host_names, host_to_slots
  
file_path: horovod/horovod/runner/common/util/hosts.py
imports: import collections
  import re
  from dataclasses import dataclass
label_desc: Use image node_id 2 for calling a global function with example usage: parse_hosts_and_slots(hosts) and returns: host_names,  host_to_slots