<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_hierarchy_probs(self, statements):
 """Sets hierarchical belief probabilities for INDRA Statements. The Statements are assumed to be in a hierarchical relation graph with the supports and supported_by attribute of each Statement object having been set. The hierarchical belief probability of each Statement is calculated based on its prior probability and the probabilities propagated from Statements supporting it in the hierarchy graph. Parameters statements : list[indra.statements.Statement] A list of INDRA Statements whose belief scores are to be calculated. Each Statement object's belief attribute is updated by this function. """

        def build_hierarchy_graph(stmts):
            """Return a DiGraph based on matches keys and Statement supports"""
            g = networkx.DiGraph()
            for st1 in stmts:
                g.add_node(st1.matches_key(), stmt=st1)
                for st2 in st1.supported_by:
                    g.add_node(st2.matches_key(), stmt=st2)
                    g.add_edge(st2.matches_key(), st1.matches_key())
            return g

        def get_ranked_stmts(g):
            """Return a topological sort of statement matches keys from a graph.
            """
            node_ranks = networkx.algorithms.dag.topological_sort(g)
            node_ranks = reversed(list(node_ranks))
            stmts = [g.node[n]['stmt'] for n in node_ranks]
            return stmts

        def assert_no_cycle(g):
            """If the graph has cycles, throws AssertionError."""
            try:
                cyc = networkx.algorithms.cycles.find_cycle(g)
            except networkx.exception.NetworkXNoCycle:
                return
            msg = 'Cycle found in hierarchy graph: %s' % cyc
            assert False, msg

        g = build_hierarchy_graph(statements)
        assert_no_cycle(g)
        ranked_stmts = get_ranked_stmts(g)
        for st in ranked_stmts:
            bps = _get_belief_package(st)
            supporting_evidences = []
            # NOTE: the last belief package in the list is this statement's own
            for bp in bps[:-1]:
                # Iterate over all the parent evidences and add only
                # non-negated ones
                for ev in bp.evidences:
                    if not ev.epistemics.get('negated'):
                        supporting_evidences.append(ev)
            # Now add the Statement's own evidence
            # Now score all the evidences
            belief = self.scorer.score_statement(st, supporting_evidences)
            st.belief = belief