code: def fetch_hostfile(hostfile_path: str, ssh_port: int) -> HostInfoList:
      """
      Parse the hostfile to obtain a list of hosts.
  
      A hostfile should look like:
      worker-0
      worker-1
      worker-2
      ...
  
      Args:
          hostfile_path (str): the path to the hostfile
          ssh_port (int): the port to connect to the host
      """
  
      if not os.path.isfile(hostfile_path):
          click.echo(
              f"Error: Unable to find the hostfile, no such file: {hostfile_path}"
          )
          exit()
  
      with open(hostfile_path, "r") as fd:
          device_pool = HostInfoList()
  
          for line in fd.readlines():
              line = line.strip()
              if line == "":
                  # skip empty lines
                  continue
  
              # build the HostInfo object
              hostname = line.strip()
              hostinfo = HostInfo(hostname=hostname, port=ssh_port)
  
              if device_pool.has(hostname):
                  click.echo(
                      f"Error: found duplicate host {hostname} in the hostfile"
                  )
                  exit()
  
              device_pool.append(hostinfo)
      return device_pool
  
file_path: ColossalAI/colossalai/cli/launcher/run.py
imports: import os
  import sys
  from typing import List
  import click
  import torch
  from packaging import version
  from colossalai.context import Config
  from .hostinfo import HostInfo, HostInfoList
  from .multinode_runner import MultiNodeRunner
label_desc: Use image node_id 1 for calling a global function with example usage: fetch_hostfile(hostfile_path, ssh_port) and returns: device_pool