def get_model_by_table(base, table):
    """
    Returns declarative class associated with given table.

    Arguments:
        base (sqlalchemy.ext.declarative.api.Base): Declarative model base or
            a subclass of the declarative model base.
        table (sqlalchemy.sql.schema.Table): SQLAlchemy Table object.

    Returns:
        class: Declarative class or None if not found.
    """
    for cls in base._decl_class_registry.values():
        if hasattr(cls, '__table__') and cls.__table__ is table:
            return cls
    return None