code: def _apply_double_dots(root: str, path: str) -> str:
      splits = [split for split in path.split("/") if split != ""]
      for split in splits:
          root = (
              "/" + os.path.join(*root.split("/")[:-1])
              if split == ".."
              else os.path.join(root, split)
          )
      return root
  
file_path: pytorch-lightning/src/lightning/app/cli/commands/cd.py
imports: import os
  from typing import Optional, Tuple, Union
  import click
  from rich.live import Live
  from rich.spinner import Spinner
  from rich.text import Text
  from lightning.app.cli.commands import ls
  from lightning.app.cli.connect.app import _LIGHTNING_CONNECTION_FOLDER
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.cli_helpers import _error_and_exit
label_desc: Use image node_id 2 for calling a global function with example usage: _apply_double_dots(root, path) and returns: root