code: def downgrade(args):
      """Downgrades the metadata database."""
      if args.to_revision and args.to_version:
          raise SystemExit(
              "Cannot supply both `--to-revision` and `--to-version`."
          )
      if args.from_version and args.from_revision:
          raise SystemExit(
              "`--from-revision` may not be combined with `--from-version`"
          )
      if (
          args.from_revision or args.from_version
      ) and not args.show_sql_only:
          raise SystemExit(
              "Args `--from-revision` and `--from-version` may only be used with `--show-sql-only`"
          )
      if not (args.to_version or args.to_revision):
          raise SystemExit(
              "Must provide either --to-revision or --to-version."
          )
      from_revision = None
      if args.from_revision:
          from_revision = args.from_revision
      elif args.from_version:
          from_revision = get_version_revision(args.from_version)
          if not from_revision:
              raise SystemExit(
                  f"Unknown version {args.from_version!r} supplied as `--from-version`."
              )
      if args.to_version:
          to_revision = get_version_revision(args.to_version)
          if not to_revision:
              raise SystemExit(
                  f"Downgrading to version {args.to_version} is not supported."
              )
      elif args.to_revision:
          to_revision = args.to_revision
      if not args.show_sql_only:
          print(
              f"Performing downgrade with database {settings.engine.url!r}"
          )
      else:
          print(
              "Generating sql for downgrade -- downgrade commands will *not* be submitted."
          )
  
      if args.show_sql_only or (
          args.yes
          or input(
              "\nWarning: About to reverse schema migrations for the airflow metastore. "
              "Please ensure you have backed up your database before any upgrade or "
              "downgrade operation. Proceed? (y/n)\n"
          ).upper()
          == "Y"
      ):
          db.downgrade(
              to_revision=to_revision,
              from_revision=from_revision,
              show_sql_only=args.show_sql_only,
          )
          if not args.show_sql_only:
              print("Downgrade complete")
      else:
          raise SystemExit("Cancelled")
  
imports: from __future__ import annotations
  import logging
  import os
  import textwrap
  import warnings
  from tempfile import NamedTemporaryFile
  from typing import TYPE_CHECKING
  from packaging.version import parse
  from tenacity import Retrying, stop_after_attempt, wait_fixed
  from airflow import settings
  from airflow.exceptions import AirflowException
  from airflow.utils import cli, db
  from airflow.utils.db import _REVISION_HEADS_MAP
  from airflow.utils.db_cleanup import config_dict, drop_archived_tables, export_archived_records, run_cleanup
  from airflow.utils.process_utils import execute_interactive
  from airflow.utils.providers_configuration_loader import providers_configuration_loaded
label_desc: Use image node_id 6 for calling a global function with example usage: downgrade(args) without return types