code: def main():
      pop = toolbox.population(n=5)
      stats = tools.Statistics(lambda ind: ind.fitness.values)
      stats.register("avg", numpy.mean)
      stats.register("std", numpy.std)
      stats.register("min", numpy.min)
      stats.register("max", numpy.max)
  
      logbook = tools.Logbook()
      logbook.header = ["gen", "evals"] + stats.fields
  
      GEN = 1000
      best = None
  
      for g in range(GEN):
          for part in pop:
              part.fitness.values = toolbox.evaluate(part)
              if not part.best or part.best.fitness < part.fitness:
                  part.best = creator.Particle(part)
                  part.best.fitness.values = part.fitness.values
              if not best or best.fitness < part.fitness:
                  best = creator.Particle(part)
                  best.fitness.values = part.fitness.values
          for part in pop:
              toolbox.update(part, best)
  
          # Gather all the fitnesses in one list and print the stats
          logbook.record(gen=g, evals=len(pop), **stats.compile(pop))
          print(logbook.stream)
  
      return pop, logbook, best
  
file_path: deap/examples/pso/basic.py
imports: import operator
  import random
  import numpy
  import math
  from deap import base
  from deap import benchmarks
  from deap import creator
  from deap import tools
label_desc: Use image node_id 3 for calling a global function with example usage: main() and returns: pop,  logbook,  best