code: def _get_conn(conn_or_engine):
      """
      Yield a connection within a transaction context.
  
      Engine.begin() returns a Connection with an implicit Transaction while
      Connection.begin() returns the Transaction. This helper will always return a
      Connection with an implicit (possibly nested) Transaction.
  
      Parameters
      ----------
      conn_or_engine : Connection or Engine
          A sqlalchemy Connection or Engine instance
      Returns
      -------
      Connection
      """
      from sqlalchemy.engine.base import Engine, Connection
  
      if isinstance(conn_or_engine, Connection):
          if not conn_or_engine.in_transaction():
              with conn_or_engine.begin():
                  yield conn_or_engine
          else:
              yield conn_or_engine
      elif isinstance(conn_or_engine, Engine):
          with conn_or_engine.begin() as conn:
              yield conn
      else:
          raise ValueError(f"Unknown Connectable: {conn_or_engine}")
  
file_path: geopandas/geopandas/io/sql.py
imports: import warnings
  from contextlib import contextmanager
  import pandas
  import shapely
  import shapely.wkb
  from geopandas import GeoDataFrame
label_desc: Use image node_id 1 for calling a global function with example usage: _get_conn(conn_or_engine) without return types