code: def get_session(mocker: MockFixture) -> Callable[[], Session]:
      """
      Create an in-memory SQLite session to test models.
      """
      engine = create_engine("sqlite://")
  
      def get_session():
          Session_ = sessionmaker(
              bind=engine
          )  # pylint: disable=invalid-name
          in_memory_session = Session_()
  
          # flask calls session.remove()
          in_memory_session.remove = lambda: None
  
          # patch session
          get_session = mocker.patch(
              "superset.security.SupersetSecurityManager.get_session",
          )
          get_session.return_value = in_memory_session
          # FAB calls get_session.get_bind() to get a handler to the engine
          get_session.get_bind.return_value = engine
          # Allow for queries on security manager
          get_session.query = in_memory_session.query
  
          mocker.patch("superset.db.session", in_memory_session)
          return in_memory_session
  
      return get_session
  
imports: import functools
  import importlib
  import os
  import unittest.mock
  from collections.abc import Iterator
  from typing import Any, Callable
  from unittest.mock import patch
  import pytest
  from _pytest.fixtures import SubRequest
  from pytest_mock import MockFixture
  from sqlalchemy import create_engine
  from sqlalchemy.orm import sessionmaker
  from sqlalchemy.orm.session import Session
  from superset import security_manager
  from superset.app import SupersetApp
  from superset.common.chart_data import ChartDataResultType
  from superset.common.query_object_factory import QueryObjectFactory
  from superset.extensions import appbuilder, feature_flag_manager
  from superset.initialization import SupersetAppInitializer
label_desc: Use image node_id 1 for calling a global function with example usage: get_session(mocker) and returns: get_session, in_memory_session