code: def find_cached_objects_in_session(
      session: Session,
      cls: type[DeclarativeModel],
      ids: Iterable[int] | None = None,
      uuids: Iterable[UUID] | None = None,
  ) -> Iterator[DeclarativeModel]:
      """Find known ORM instances in cached SQLA session states.
  
      :param session: a SQLA session
      :param cls: a SQLA DeclarativeModel
      :param ids: ids of the desired model instances (optional)
      :param uuids: uuids of the desired instances, will be ignored if `ids` are provides
      """
      if not ids and not uuids:
          return iter([])
      uuids = uuids or []
      try:
          items = list(session)
      except ObjectDeletedError:
          logger.warning("ObjectDeletedError", exc_info=True)
          return iter(())
  
      return (
          item
          # `session` is an iterator of all known items
          for item in items
          if isinstance(item, cls)
          and (item.id in ids if ids else item.uuid in uuids)
      )
  
imports: from __future__ import annotations
  import logging
  from collections.abc import Iterable, Iterator
  from functools import lru_cache
  from typing import Callable, TYPE_CHECKING, TypeVar
  from uuid import UUID
  from flask_babel import lazy_gettext
  from sqlalchemy.engine.url import URL
  from sqlalchemy.exc import NoSuchTableError
  from sqlalchemy.ext.declarative import DeclarativeMeta
  from sqlalchemy.orm import Session
  from sqlalchemy.orm.exc import ObjectDeletedError
  from sqlalchemy.sql.type_api import TypeEngine
  from superset.constants import LRU_CACHE_MAX_SIZE
  from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
  from superset.exceptions import SupersetGenericDBErrorException, SupersetSecurityException
  from superset.models.core import Database
  from superset.result_set import SupersetResultSet
  from superset.sql_parse import ParsedQuery
  from superset.superset_typing import ResultSetColumnType
label_desc: Use image node_id 6 for calling a global function with example usage: find_cached_objects_in_session(session, cls, ids, uuids) and returns: unknown, iter, iter