code: def init_test_engine_and_session_factory(
      tier_or_path: Optional[str] = None,
      echo: bool = False,
      force_init: bool = False,
      **kwargs: Any,
  ) -> None:
      """Initialize the global engine and SESSION_FACTORY for SQLAlchemy,
      using an in-memory SQLite database.
  
      The initialization needs to only happen once. Note that it is possible to
      re-initialize the engine by setting the `force_init` flag to True, but this
      should only be used if you are absolutely certain that you know what you
      are doing.
  
      Args:
          tier_or_path: the name of the DB tier.
          echo: if True, logging for engine is enabled.
          force_init: if True, allows re-initializing engine
              and session factory.
          **kwargs: keyword arguments passed to `create_mysql_engine_from_creator`
  
      """
      global SESSION_FACTORY
  
      if SESSION_FACTORY is not None:
          if force_init:
              SESSION_FACTORY.bind.dispose()
          else:
              return
      engine = create_test_engine(path=tier_or_path, echo=echo)
      create_all_tables(engine)
  
      SESSION_FACTORY = scoped_session(
          sessionmaker(bind=engine, expire_on_commit=EXPIRE_ON_COMMIT)
      )
  
file_path: Ax/ax/storage/sqa_store/db.py
imports: from __future__ import annotations
  from contextlib import contextmanager
  from typing import Any, Callable, Generator, Optional, TypeVar
  from sqlalchemy import create_engine
  from sqlalchemy.engine.base import Engine
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import scoped_session, Session, sessionmaker
label_desc: Use image node_id 5 for calling a global function with example usage: init_test_engine_and_session_factory(tier_or_path, echo, force_init) without return types