code: def retry_transient_mysql_errors(
      f: Callable[P, Awaitable[T]]
  ) -> Callable[P, Awaitable[T]]:
      @functools.wraps(f)
      async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
          tries = 0
          while True:
              try:
                  return await f(*args, **kwargs)
              except pymysql.err.InternalError as e:
                  if e.args[0] in internal_error_retry_codes:
                      log.warning(
                          f"encountered pymysql error, retrying {e}",
                          exc_info=True,
                          extra={
                              "full_stacktrace": "\n".join(
                                  traceback.format_stack()
                              )
                          },
                      )
                  else:
                      raise
              except pymysql.err.OperationalError as e:
                  if e.args[0] in operational_error_retry_codes:
                      log.warning(
                          f"encountered pymysql error, retrying {e}",
                          exc_info=True,
                          extra={
                              "full_stacktrace": "\n".join(
                                  traceback.format_stack()
                              )
                          },
                      )
                  else:
                      raise
              tries += 1
              await sleep_before_try(tries)
  
      return wrapper
  
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 1 for calling a global function with example usage: retry_transient_mysql_errors(f) and returns: wrapper, unknown