code: def cleanup(all: bool):
      if all:
          get_console().print(
              "\n[info]Removing cache of parameters, clean up docker cache "
              "and remove locally downloaded images[/]"
          )
      else:
          get_console().print(
              "[info]Removing cache of parameters, and cleans up docker cache[/]"
          )
      if all:
          docker_images_command_to_execute = [
              "docker",
              "images",
              "--filter",
              "label=org.apache.airflow.image",
              "--format",
              "{{.Repository}}:{{.Tag}}",
          ]
          command_result = run_command(
              docker_images_command_to_execute,
              text=True,
              capture_output=True,
          )
          images = (
              command_result.stdout.splitlines()
              if command_result and command_result.stdout
              else []
          )
          if images:
              get_console().print("[info]Removing images:[/]")
              for image in images:
                  get_console().print(f"[info] * {image}[/]")
              get_console().print()
              docker_rmi_command_to_execute = [
                  "docker",
                  "rmi",
                  "--force",
              ]
              docker_rmi_command_to_execute.extend(images)
              given_answer = user_confirm(
                  "Are you sure with the removal?"
              )
              if given_answer == Answer.YES:
                  run_command(
                      docker_rmi_command_to_execute, check=False
                  )
              elif given_answer == Answer.QUIT:
                  sys.exit(0)
          else:
              get_console().print(
                  "[info]No locally downloaded images to remove[/]\n"
              )
      get_console().print("Removing unused networks")
      given_answer = user_confirm(
          "Are you sure with the removal of unused docker networks?"
      )
      if given_answer == Answer.YES:
          remove_docker_networks()
      get_console().print("Pruning docker images")
      given_answer = user_confirm(
          "Are you sure with the removal of docker images?"
      )
      if given_answer == Answer.YES:
          system_prune_command_to_execute = [
              "docker",
              "system",
              "prune",
              "-f",
          ]
          run_command(
              system_prune_command_to_execute,
              check=False,
          )
      elif given_answer == Answer.QUIT:
          sys.exit(0)
      get_console().print(f"Removing build cache dir {BUILD_CACHE_DIR}")
      given_answer = user_confirm("Are you sure with the removal?")
      if given_answer == Answer.YES:
          if not get_dry_run():
              shutil.rmtree(BUILD_CACHE_DIR, ignore_errors=True)
      elif given_answer == Answer.QUIT:
          sys.exit(0)
  
imports: from __future__ import annotations
  import platform
  import shutil
  import subprocess
  import sys
  from typing import TYPE_CHECKING, Any
  from airflow_breeze.commands.ci_image_commands import ci_image
  from airflow_breeze.commands.common_options import option_answer, option_backend, option_builder, option_database_isolation, option_db_reset, option_docker_host, option_dry_run, option_forward_credentials, option_github_repository, option_integration, option_max_time, option_mysql_version, option_postgres_version, option_project_name, option_python, option_standalone_dag_processor, option_verbose
  from airflow_breeze.commands.production_image_commands import prod_image
  from airflow_breeze.commands.testing_commands import group_for_testing
  from airflow_breeze.configure_rich_click import click
  from airflow_breeze.utils.click_utils import BreezeGroup
  from airflow_breeze.utils.confirm import Answer, user_confirm
  from airflow_breeze.utils.console import get_console
  from airflow_breeze.utils.docker_command_utils import remove_docker_networks
  from airflow_breeze.utils.path_utils import BUILD_CACHE_DIR
  from airflow_breeze.utils.run_utils import run_command
  from airflow_breeze.utils.shared_options import get_dry_run
label_desc: Use image node_id 5 for calling a global function with example usage: cleanup(all) without return types