code: def attach(self):
      include_ssh_config(self.ssh_config_path)
      if self.container_config is None:
          update_ssh_config(
              self.ssh_config_path, self.run_name, self.host_config
          )
      else:
          update_ssh_config(
              self.ssh_config_path,
              f"{self.run_name}-host",
              self.host_config,
          )
          update_ssh_config(
              self.ssh_config_path, self.run_name, self.container_config
          )
  
      max_retries = 10
      self._ports_lock.release()
      for i in range(max_retries):
          try:
              self.tunnel.open()
              atexit.register(self.detach)
              break
          except SSHError:
              if i < max_retries - 1:
                  time.sleep(1)
      else:
          self.detach()
          raise SSHError("Can't connect to the remote host")
  
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 3 for calling the SSHAttach obj's underlying member method code with example usage: obj.attach() without return types