code: def create_airflow_home(create_user, tmp_path, monkeypatch):
      sql_alchemy_conn = conf.get_mandatory_value(
          "database", "sql_alchemy_conn"
      )
      username = create_user
      airflow_home = tmp_path / "airflow-home"
  
      if not airflow_home.exists():
          airflow_home.mkdir(parents=True, exist_ok=True)
  
      permissions = {
          # By default, ``tmp_path`` save temporary files/directories in user temporary directory
          # something like: `/tmp/pytest-of-root` and other users might be limited to access to it,
          # so we need to grant at least r/o access to everyone.
          airflow_home: 0o777,
          # Grant full access to system-wide temporary directory (if for some reason it not set)
          tempfile.gettempdir(): 0o777,
      }
  
      if sql_alchemy_conn.lower().startswith("sqlite"):
          sqlite_file = Path(sql_alchemy_conn.replace("sqlite:///", ""))
          # Grant r/w access to sqlite file.
          permissions[sqlite_file] = 0o766
          # Grant r/w access to directory where sqlite file placed
          # otherwise we can't create temporary files during write access.
          permissions[sqlite_file.parent] = 0o777
  
      monkeypatch.setenv("AIRFLOW_HOME", str(airflow_home))
  
      with set_permissions(permissions):
          subprocess.check_call(
              [
                  "sudo",
                  "chown",
                  f"{username}:root",
                  str(airflow_home),
                  "-R",
              ],
              close_fds=True,
          )
          yield airflow_home
  
imports: from __future__ import annotations
  import contextlib
  import logging
  import os
  import subprocess
  import sys
  import tempfile
  from pathlib import Path
  import pytest
  from airflow.configuration import conf
  from airflow.jobs.backfill_job_runner import BackfillJobRunner
  from airflow.jobs.job import Job, run_job
  from airflow.models import DagBag, DagRun, TaskInstance
  from airflow.utils.db import add_default_pool_if_not_exists
  from airflow.utils.state import State
  from airflow.utils.timezone import datetime
  from airflow.utils.types import DagRunType
  from tests.test_utils import db
label_desc: Use image node_id 4 for calling a global function with example usage: create_airflow_home(create_user, tmp_path, monkeypatch) without return types