<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def solution(swarm):
 """ Determines the global best particle in the swarm. Args: swarm: iterable: an iterable that yields all particles in the swarm. Returns: cipy.algorithms.pso.Particle: The best particle in the swarm when comparing the best_fitness values of the particles. """

    best = swarm[0]
    cmp = comparator(best.best_fitness)
    for particle in swarm:
        if cmp(particle.best_fitness, best.best_fitness):
            best = particle
    return best