code: def should_set_tablename(cls: type) -> bool:
      """Determine whether ``__tablename__`` should be generated for a model.
  
      -   If no class in the MRO sets a name, one should be generated.
      -   If a declared attr is found, it should be used instead.
      -   If a name is found, it should be used if the class is a mixin, otherwise one
          should be generated.
      -   Abstract models should not have one generated.
  
      Later, ``__table_cls__`` will determine if the model looks like single or
      joined-table inheritance. If no primary key is found, the name will be unset.
      """
      if (
          cls.__dict__.get("__abstract__", False)
          or (
              not issubclass(
                  cls,
                  (
                      sa_orm.DeclarativeBase,
                      sa_orm.DeclarativeBaseNoMeta,
                  ),
              )
              and not any(
                  isinstance(b, sa_orm.DeclarativeMeta)
                  for b in cls.__mro__[1:]
              )
          )
          or any(
              (
                  b is sa_orm.DeclarativeBase
                  or b is sa_orm.DeclarativeBaseNoMeta
              )
              for b in cls.__bases__
          )
      ):
          return False
  
      for base in cls.__mro__:
          if "__tablename__" not in base.__dict__:
              continue
  
          if isinstance(
              base.__dict__["__tablename__"], sa_orm.declared_attr
          ):
              return False
  
          return not (
              base is cls
              or base.__dict__.get("__abstract__", False)
              or not (
                  # SQLAlchemy 1.x
                  isinstance(base, sa_orm.DeclarativeMeta)
                  # 2.x: DeclarativeBas uses this as metaclass
                  or isinstance(
                      base,
                      sa_orm.decl_api.DeclarativeAttributeIntercept,
                  )
                  # 2.x: DeclarativeBaseNoMeta doesn't use a metaclass
                  or issubclass(base, sa_orm.DeclarativeBaseNoMeta)
              )
          )
  
      return True
  
imports: from __future__ import annotations
  import re
  import typing
  import sqlalchemy
  import sqlalchemy.orm
  from .query import Query
label_desc: Use image node_id 1 for calling a global function with example usage: should_set_tablename(cls) and returns: True, False, unknown, False