code: def find_free_network_port() -> int:
      """Finds a free port on localhost.
  
      It is useful in single-node training when we don't want to connect to a real master node but have to set the
      `MASTER_PORT` environment variable.
      """
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.bind(("", 0))
      s.listen(1)
      port = s.getsockname()[1]
      s.close()
      return port
  
imports: import os, sys
  import socket
  from typing import Union
  import numpy
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
label_desc: Use image node_id 2 for calling a global function with example usage: find_free_network_port() and returns: port