<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_jobs_status(self, fail_running=False, fail_pending=False):
 """Check the status of all the jobs run from this link and return a status flag that summarizes that. Parameters fail_running : `bool` If True, consider running jobs as failed fail_pending : `bool` If True, consider pending jobs as failed Returns ------- status : `JobStatus` Job status flag that summarizes the status of all the jobs, """


        n_failed = 0
        n_partial = 0
        n_passed = 0
        n_total = 0
        for job_details in self.jobs.values():
            n_total += 1
            if job_details.status in [JobStatus.failed, JobStatus.partial_failed]:
                n_failed += 1
            elif fail_running and job_details.status == JobStatus.running:
                n_failed += 1
            elif fail_pending and job_details.status == JobStatus.pending:
                n_failed += 1
            elif job_details.status == JobStatus.done:
                n_passed += 1

        if n_failed > 0:
            return JobStatus.failed
        elif n_passed == n_total:
            return JobStatus.done
        elif n_passed > 0:
            return JobStatus.running

        return JobStatus.pending