code: def reuse_control_sock_path_and_port_locks(
      run_name: str,
  ) -> Optional[Tuple[str, PortsLock]]:
      ssh_config_path = str(ConfigManager().dstack_ssh_config_path)
      host_config = get_ssh_config(ssh_config_path, run_name)
      if host_config and host_config.get("ControlPath"):
          ps = subprocess.Popen(
              ("ps", "-A", "-o", "command"), stdout=subprocess.PIPE
          )
          control_sock_path = host_config.get("ControlPath")
          output = subprocess.check_output(
              ("grep", control_sock_path), stdin=ps.stdout
          )
          ps.wait()
          commands = list(
              filter(
                  lambda s: not s.startswith("grep"),
                  output.decode().strip().split("\n"),
              )
          )
          if commands:
              port_pattern = r"-L (\d+):localhost:(\d+)"
              matches = re.findall(port_pattern, commands[0])
              return control_sock_path, PortsLock(
                  {
                      int(local_port): int(target_port)
                      for local_port, target_port in matches
                  }
              )
      return None
  
file_path: dstack/src/dstack/_internal/core/services/ssh/attach.py
imports: import atexit
  import re
  import subprocess
  import time
  from typing import Optional, Tuple
  from dstack._internal.core.errors import SSHError
  from dstack._internal.core.services.configs import ConfigManager
  from dstack._internal.core.services.ssh.ports import PortsLock
  from dstack._internal.core.services.ssh.tunnel import ClientTunnel
  from dstack._internal.utils.path import PathLike
  from dstack._internal.utils.ssh import get_ssh_config, include_ssh_config, update_ssh_config
label_desc: Use image node_id 1 for calling the SSHAttach obj's underlying member method code with example usage: obj.reuse_control_sock_path_and_port_locks(run_name) and returns: None, control_sock_path,  PortsLock