code: def add_subcommand_completions(ctx, incomplete, completions_out):
      # Add subcommand completions.
      if isinstance(ctx.command, MultiCommand):
          completions_out.extend(
              [
                  (c.name, c.get_short_help_str())
                  for c in get_visible_commands_starting_with(
                      ctx, incomplete
                  )
              ]
          )
  
      # Walk up the context list and add any other completion
      # possibilities from chained commands
      while ctx.parent is not None:
          ctx = ctx.parent
          if (
              isinstance(ctx.command, MultiCommand)
              and ctx.command.chain
          ):
              remaining_commands = [
                  c
                  for c in get_visible_commands_starting_with(
                      ctx, incomplete
                  )
                  if c.name not in ctx.protected_args
              ]
              completions_out.extend(
                  [
                      (c.name, c.get_short_help_str())
                      for c in remaining_commands
                  ]
              )
  
imports: import copy
  import os
  import re
  from .core import Argument
  from .core import MultiCommand
  from .core import Option
  from .parser import split_arg_string
  from .types import Choice
  from .utils import echo
label_desc: Use image node_id 8 for calling a global function with example usage: add_subcommand_completions(ctx, incomplete, completions_out) without return types