docs: def collect_hosts(hosts, randomize=True):
      """
      Collects a comma-separated set of hosts (host:port) and optionally
      randomize the returned list.
      """
  
      if isinstance(hosts, six.string_types):
          hosts = hosts.strip().split(',')
  
      result = []
      afi = socket.AF_INET
      for host_port in hosts:
  
          host, port, afi = get_ip_port_afi(host_port)
  
          if port < 0:
              port = DEFAULT_KAFKA_PORT
  
          result.append((host, port, afi))
  
      if randomize:
          shuffle(result)
  
      return result