<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ncores_allocated(self):
 """ Returns the number of CPUs allocated in this moment. A core is allocated if it's running a task or if we have submitted a task to the queue manager but the job is still pending. """

        return sum(task.manager.num_cores for task in self if task.status in [task.S_SUB, task.S_RUN])