code: def test_custom_scope(app: Flask, model_class: t.Any) -> None:
      count = 0
  
      def scope() -> int:
          nonlocal count
          count += 1
          return count
  
      db = SQLAlchemy(
          app,
          model_class=model_class,
          session_options={"scopefunc": scope},
      )
  
      with app.app_context():
          first = db.session()
          second = db.session()
          assert (
              first is not second
          )  # a new scope is generated on each call
          first.close()
          second.close()
  
file_path: flask-sqlalchemy/tests/test_session.py
imports: from __future__ import annotations
  import typing
  import pytest
  import sqlalchemy
  import sqlalchemy.orm
  from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_sqlalchemy.session import Session
label_desc: Use image node_id 2 for calling a global function with example usage: test_custom_scope(app, model_class) and returns: count