code: def _find_selected_app_instance_id(app_name: str) -> str:
      console = Console()
      app_manager = _AppManager()
  
      all_app_names_and_ids = {}
      selected_app_instance_id = None
  
      for app in app_manager.list_apps():
          all_app_names_and_ids[app.name] = app.id
          # figure out the ID of some app_name
          if app_name == app.name or app_name == app.id:
              selected_app_instance_id = app.id
              break
  
      if selected_app_instance_id is None:
          # when there is no app with the given app_name,
          # ask the user which app they would like to delete.
          console.print(
              f'[b][yellow]Cannot find app named "{app_name}"[/yellow][/b]'
          )
          try:
              ask = [
                  inquirer.List(
                      "app_name",
                      message="Select the app name to delete",
                      choices=list(all_app_names_and_ids.keys()),
                  ),
              ]
              app_name = inquirer.prompt(
                  ask,
                  theme=GreenPassion(),
                  raise_keyboard_interrupt=True,
              )["app_name"]
              selected_app_instance_id = all_app_names_and_ids[app_name]
          except KeyboardInterrupt:
              console.print("[b][red]Cancelled by user![/b][/red]")
              raise InterruptedError
  
      return selected_app_instance_id
  
file_path: pytorch-lightning/src/lightning/app/cli/lightning_cli_delete.py
imports: import click
  import inquirer
  from inquirer.themes import GreenPassion
  from rich.console import Console
  from lightning.app.cli.cmd_apps import _AppManager
label_desc: Use image node_id 2 for calling a global function with example usage: _find_selected_app_instance_id(app_name) and returns: selected_app_instance_id