def METHOD_NAME(Base):
    catalog_category = sa.Table(
        'catalog_category',
        Base.metadata,
        sa.Column('catalog_id', sa.Integer, sa.ForeignKey('catalog.id')),
        sa.Column('category_id', sa.Integer, sa.ForeignKey('category.id'))
    )
    class METHOD_NAME(Base):
        __tablename__ = 'catalog'
        id = sa.Column(sa.Integer, primary_key=True)
        product_count = sa.Column(sa.Integer, default=0)
        @observes('categories.sub_categories.products')
        def product_observer(self, products):
            self.product_count = len(products)
        categories = sa.orm.relationship(
            'Category',
            backref='catalogs',
            secondary=catalog_category
        )
    return METHOD_NAME