code: def init_engine_and_session_factory(
      url: Optional[str] = None,
      # pyre-fixme[24]: Generic type `Callable` expects 2 type parameters.
      creator: Optional[Callable] = None,
      echo: bool = False,
      force_init: bool = False,
      **kwargs: Any,
  ) -> None:
      """Initialize the global engine and SESSION_FACTORY for SQLAlchemy.
  
      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:
          url: a database url that can include username, password, hostname, database name
              as well as optional keyword arguments for additional configuration.
              e.g. `dialect+driver://username:password@host:port/database`.
              Either this argument or `creator` argument must be specified.
          creator: a callable which returns a DBAPI connection.
              Either this argument or `url` argument must be specified.
          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
      if url is not None:
          engine = create_mysql_engine_from_url(
              url=url, echo=echo, **kwargs
          )
      elif creator is not None:
          engine = create_mysql_engine_from_creator(
              creator=creator, echo=echo, **kwargs
          )
      else:
          raise ValueError("Must specify either `url` or `creator`.")
      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 4 for calling a global function with example usage: init_engine_and_session_factory(url, creator, echo, force_init) without return types