code: def transaction(db: "Database", read_only: bool = False):
      def transformer(
          fun: Callable[Concatenate["Transaction", P], Awaitable[T]]
      ) -> Callable[P, Awaitable[T]]:
          @functools.wraps(fun)
          @retry_transient_mysql_errors
          async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
              async with db.start(read_only=read_only) as tx:
                  return await fun(tx, *args, **kwargs)
  
          return wrapper
  
      return transformer
  
imports: import asyncio
  import contextlib
  import functools
  import logging
  import os
  import ssl
  import traceback
  from typing import Any, AsyncIterator, Awaitable, Callable, Dict, Optional, TypeVar
  import aiomysql
  import aiomysql.utils
  import kubernetes_asyncio.client
  import kubernetes_asyncio.config
  import pymysql
  from typing_extensions import Concatenate, ParamSpec
  from gear.metrics import DB_CONNECTION_QUEUE_SIZE, SQL_TRANSACTIONS, PrometheusSQLTimer
  from hailtop.aiotools import BackgroundTaskManager
  from hailtop.auth.sql_config import SQLConfig
  from hailtop.config import get_deploy_config
  from hailtop.utils import first_extant_file, sleep_before_try
label_desc: Use image node_id 2 for calling a global function with example usage: transaction(db, read_only) and returns: transformer, wrapper, unknown