<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def state_probability(self, direction, repertoire, purview,):
 """Compute the probability of the purview in its current state given the repertoire. Collapses the dimensions of the repertoire that correspond to the purview nodes onto their state. All other dimension are already singular and thus receive 0 as the conditioning index. Returns: float: A single probabilty. """

        purview_state = self.purview_state(direction)

        index = tuple(node_state if node in purview else 0
                      for node, node_state in enumerate(purview_state))
        return repertoire[index]