code: def get_errors_and_hooks(
      content: Any, max_length: int
  ) -> tuple[list[str], dict[str, list[str]], list[str]]:
      errors = []
      hooks: dict[str, list[str]] = defaultdict(list)
      needs_image = False
      image_hooks = []
      for repo in content["repos"]:
          for hook in repo["hooks"]:
              if "id" in hook:
                  hook_id = hook["id"]
              else:
                  errors.append(f"The id is missing in {hook}")
                  continue
              if hook_id == "mypy-dev":
                  needs_image = True
              if "name" not in hook:
                  errors.append(
                      f"Name is missing in hook `{hook_id}` in {PRE_COMMIT_YAML_FILE}. Please add it!"
                  )
                  continue
              name = hook["name"]
              if len(name) > max_length:
                  errors.append(
                      f"Name is too long for hook `{hook_id}` in {PRE_COMMIT_YAML_FILE}. Please shorten it!"
                  )
                  continue
              hooks[hook_id].append(name)
              if needs_image:
                  image_hooks.append(hook_id)
      return errors, hooks, image_hooks
  
file_path: airflow/scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py
imports: from __future__ import annotations
  import argparse
  import sys
  from pathlib import Path
  from collections import defaultdict
  from typing import Any
  import yaml
  from common_precommit_black_utils import black_format
  from common_precommit_utils import AIRFLOW_BREEZE_SOURCES_PATH, AIRFLOW_SOURCES_ROOT_PATH, insert_documentation
  from rich.console import Console
  from tabulate import tabulate
label_desc: Use image node_id 1 for calling a global function with example usage: get_errors_and_hooks(content, max_length) and returns: errors,  hooks,  image_hooks