code: def session_scope(engine: Engine) -> Session:
      """returns a sqlalchemy session using the provided engine
  
      This contextmanager commits all pending session changes on scope exit,
      and on an exception rolls back pending changes. The returned session is
      closed on final scope exit.
  
      Args:
      engine: sqlalchemy engine
  
      Returns:
      Session
      """
      session = sessionmaker(bind=engine)()
      try:
          yield session
          session.commit()
      except:
          session.rollback()
          raise
      finally:
          session.close()
  
imports: import os
  import sys
  from contextlib import contextmanager
  from copy import deepcopy
  from typing import Any, Dict, List, Optional
  from absl import logging
  from blessings import Terminal
  from googleapiclient import discovery
  from sqlalchemy import create_engine
  from sqlalchemy.engine.base import Engine
  from sqlalchemy.exc import OperationalError
  from sqlalchemy.orm import Session, sessionmaker
  import caliban.config.experiment
  import caliban.util.auth
  from caliban.history.types import ContainerSpec, Experiment, ExperimentGroup, Job, JobSpec, JobStatus, Platform, init_db
  from caliban.platform.cloud.types import JobStatus
  from caliban.platform.gke.cluster import Cluster
  from caliban.platform.gke.types import JobStatus
  from caliban.platform.gke.util import default_credentials
label_desc: Use image node_id 4 for calling a global function with example usage: session_scope(engine) without return types