<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_upstream_trigger(self) -> bool: """Checks the upstream and the trigger rule."""

        if self.operation.trigger_policy == TriggerPolicy.ONE_DONE:
            return self.upstream_runs.filter(
                status__status__in=self.STATUSES.DONE_STATUS).exists()
        if self.operation.trigger_policy == TriggerPolicy.ONE_SUCCEEDED:
            return self.upstream_runs.filter(
                status__status=self.STATUSES.SUCCEEDED).exists()
        if self.operation.trigger_policy == TriggerPolicy.ONE_FAILED:
            return self.upstream_runs.filter(
                status__status=self.STATUSES.FAILED).exists()

        statuses = self.upstream_runs.values_list('status__status', flat=True)
        if self.operation.trigger_policy == TriggerPolicy.ALL_DONE:
            return not bool([True for status in statuses
                             if status not in self.STATUSES.DONE_STATUS])
        if self.operation.trigger_policy == TriggerPolicy.ALL_SUCCEEDED:
            return not bool([True for status in statuses
                             if status != self.STATUSES.SUCCEEDED])
        if self.operation.trigger_policy == TriggerPolicy.ALL_FAILED:
            return not bool([True for status in statuses
                             if status not in self.STATUSES.FAILED_STATUS])