A labeling platform routes tasks to annotators and models. Each task can only go to workers qualified for it, and each worker has a limit on how many tasks it takes. First assign as many tasks as possible; then, among assignments that reach that number, make the busiest worker as lightly loaded as possible.
Implement assign_tasks(qualified, capacity):
qualified: a list with one entry per task; qualified[t] is a list of worker indices (in range(len(capacity))) allowed to do task t. It may be empty or contain repeats.capacity: a list of non-negative integers; worker w may take at most capacity[w] tasks.Each task goes to at most one qualified worker. Return a tuple (max_assigned, min_max_load):
max_assigned: the largest number of tasks that can be assigned.min_max_load: the smallest integer such that max_assigned tasks can still be assigned when every worker's limit is lowered to . Return 0 when max_assigned is 0.