code: def add_optional_command(name, module, function, parent):
      try:
          module = importlib.import_module(module, package="archery")
          command = getattr(module, function)
      except ImportError as exc:
          error_message = exc.name
  
          @parent.command(
              name,
              context_settings={
                  "allow_extra_args": True,
                  "ignore_unknown_options": True,
              },
          )
          def command():
              raise click.ClickException(
                  f"Couldn't import command `{name}` due to {error_message}"
              )
  
      else:
          parent.add_command(command)
  
file_path: arrow/dev/archery/archery/utils/cli.py
imports: import importlib
  import click
  from .source import ArrowSources, InvalidArrowSource
label_desc: Use image node_id 2 for calling a global function with example usage: add_optional_command(name, module, function, parent) without return types