code: def find_free_ports(num):
      """
      在空闲的端口中找到 ``num`` 个端口
      """
  
      def __free_port():
          with closing(
              socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          ) as s:
              s.setsockopt(
                  socket.SOL_SOCKET,
                  socket.SO_LINGER,
                  struct.pack("ii", 1, 0),
              )
              s.bind(("", 0))
              return s.getsockname()[1]
  
      port_set = set()
      step = 0
      while True:
          port = __free_port()
          if port not in port_set:
              port_set.add(port)
  
          if len(port_set) >= num:
              return port_set
  
          step += 1
          if step > 400:
              logger.error(
                  "can't find avilable port and use the specified static port now!"
              )
              return None
  
      return None
  
imports: import socket
  import os
  import struct
  import random
  import inspect
  import numpy
  from copy import deepcopy
  from contextlib import ExitStack, closing
  from typing import Dict, Optional
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
  from fastNLP.envs.utils import get_global_seed
  from fastNLP.envs import get_global_rank, FASTNLP_BACKEND_LAUNCH, FASTNLP_GLOBAL_SEED
  from fastNLP.core.samplers import ReproducibleBatchSampler
  from fastNLP.core.utils import auto_param_call, paddle_to
  from fastNLP.core.log import logger
label_desc: Use image node_id 3 for calling a global function with example usage: find_free_ports(num) and returns: None, s, port_set, None