<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def facts(self, fields=None, cuts=None, order=None, page=None, page_size=None, page_max=None):
 """ List all facts in the cube, returning only the specified references if these are specified. """


        def prep(cuts, columns=None):
            q = select(columns=columns).select_from(self.fact_table)
            bindings = []
            _, q, bindings = Cuts(self).apply(q, bindings, cuts)
            q = self.restrict_joins(q, bindings)
            return q, bindings

        # Count
        count = count_results(self, prep(cuts, [1])[0])

        # Facts
        q, bindings = prep(cuts)
        fields, q, bindings = Fields(self).apply(q, bindings, fields)
        ordering, q, bindings = Ordering(self).apply(q, bindings, order)
        page, q = Pagination(self).apply(q, page, page_size, page_max)
        q = self.restrict_joins(q, bindings)
        return {
            'total_fact_count': count,
            'data': list(generate_results(self, q)),
            'cell': cuts,
            'fields': fields,
            'order': ordering,
            'page': page['page'],
            'page_size': page['page_size']
        }