code: def main():
      random.seed(1024)
  
      pop = toolbox.population(n=100)
      hof = tools.HallOfFame(1)
      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", "std", "min", "avg", "max"
  
      CXPB, MUTPB, NGEN = 0.5, 0.2, 40
  
      # Evaluate the entire population
      for ind in pop:
          ind.fitness.values = toolbox.evaluate(ind)
  
      hof.update(pop)
      record = stats.compile(pop)
      logbook.record(gen=0, evals=len(pop), **record)
      print(logbook.stream)
  
      for g in range(1, NGEN):
          # Select the offspring
          offspring = toolbox.select(pop, len(pop))
          # Clone the offspring
          offspring = [toolbox.clone(ind) for ind in offspring]
  
          # Apply crossover and mutation
          for ind1, ind2 in zip(offspring[::2], offspring[1::2]):
              for tree1, tree2 in zip(ind1, ind2):
                  if random.random() < CXPB:
                      toolbox.mate(tree1, tree2)
                      del ind1.fitness.values
                      del ind2.fitness.values
  
          for ind in offspring:
              for tree, pset in zip(ind, psets):
                  if random.random() < MUTPB:
                      toolbox.mutate(individual=tree, pset=pset)
                      del ind.fitness.values
  
          # Evaluate the individuals with an invalid fitness
          invalids = [ind for ind in offspring if not ind.fitness.valid]
          for ind in invalids:
              ind.fitness.values = toolbox.evaluate(ind)
  
          # Replacement of the population by the offspring
          pop = offspring
          hof.update(pop)
          record = stats.compile(pop)
          logbook.record(gen=g, evals=len(invalids), **record)
          print(logbook.stream)
  
      print("Best individual : ", hof[0][0], hof[0].fitness)
  
      return pop, stats, hof
  
file_path: deap/examples/gp/adf_symbreg.py
imports: import random
  import operator
  import math
  import numpy
  from functools import partial
  from deap import base
  from deap import creator
  from deap import gp
  from deap import tools
label_desc: Use image node_id 3 for calling a global function with example usage: main() and returns: pop,  stats,  hof