class_docstr: 复原了 paddle 的 launch_collective 函数，将其简化后集成到一个类里
  仅支持每个机器单卡的情况。
class_docstr_tok: ["\u590d\u539f\u4e86","paddle","\u7684","launch_collective","\u51fd\u6570\uff0c\u5c06\u5176\u7b80\u5316\u540e\u96c6\u6210\u5230\u4e00\u4e2a\u7c7b\u91cc","\u4ec5\u652f\u6301\u6bcf\u4e2a\u673a\u5668\u5355\u5361\u7684\u60c5\u51b5\u3002"]
docstr: 寻找用户设置的端口或是空闲端口用于分布式训练，参考了 PaddlePaddle 中的 `get_cluster_from_args` 函数
docstr_tok: ["\u5bfb\u627e\u7528\u6237\u8bbe\u7f6e\u7684\u7aef\u53e3\u6216\u662f\u7a7a\u95f2\u7aef\u53e3\u7528\u4e8e\u5206\u5e03\u5f0f\u8bad\u7ec3\uff0c\u53c2\u8003\u4e86","PaddlePaddle","\u4e2d\u7684","`","get_cluster_from_args","`","\u51fd\u6570"]
code: def set_endpoints(self):
      """
      寻找用户设置的端口或是空闲端口用于分布式训练，参考了 PaddlePaddle 中的 `get_cluster_from_args` 函数
      """
      self.node_ip = "127.0.0.1"
  
      free_ports = None
      if os.environ.get("FLAGS_START_PORT") is None:
          free_ports = find_free_ports(len(self.devices))
          if free_ports is not None:
              free_ports = list(free_ports)
      else:
          start_port = int(os.getenv("FLAGS_START_PORT", "6070"))
  
          free_ports = [
              x
              for x in range(start_port, start_port + len(self.devices))
          ]
  
      self.endpoints = [
          "%s:%d" % (self.node_ip, port) for port in free_ports
      ]
  
imports: import os
  import sys
  import __main__
  import tempfile
  import copy
  from typing import List
  from fastNLP.core.drivers.utils import distributed_open_proc
  from fastNLP.envs.env import FASTNLP_DISTRIBUTED_CHECK, FASTNLP_LOG_LEVEL, FASTNLP_GLOBAL_SEED, FASTNLP_GLOBAL_RANK
  from fastNLP.core.utils import get_paddle_device_id
  from .utils import find_free_ports
label_desc: Use image node_id 6 for calling the FleetLauncher obj's underlying member method code with example usage: obj.set_endpoints() without return types