code: def free_port():
      """Find free port using bind().
  
      There are some interval between finding this port and using it
      and the other process might catch the port by that time.
      Thus it is not guaranteed that the port is really empty.
  
      """
      # This method is copied from ESPnet v2's utility below.
      # https://github.com/espnet/espnet/blob/43ce0c69fb32961235534b348700dc6c74ad5792/espnet2/train/distributed_utils.py#L187-L198
      with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
          sock.bind(("", 0))
          return sock.getsockname()[1]
  
file_path: espnet/espnet/distributed/pytorch_backend/launch.py
imports: import multiprocessing
  import os
  import signal
  import socket
  import time
label_desc: Use image node_id 2 for calling a global function with example usage: free_port() and returns: sock