<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def failure_reason(self, failure_index=None):
 """Get the reason for a failure. Args: failure_index: Index of the fail to return the graph for (can be negative). If None, the most appropriate failure is chosen according to these rules: - If the fail is cyclic, the most recent fail (the one containing the cycle) is used; - If a callback has caused a failure, the most recent fail is used; - Otherwise, the first fail is used. Returns: A `FailureReason` subclass instance describing the failure. """

        phase, _ = self._get_failed_phase(failure_index)
        return phase.failure_reason