code: def main(procid, pipein, pipeout, sync, seed=None):
      random.seed(seed)
      toolbox.register(
          "migrate",
          migPipe,
          k=5,
          pipein=pipein,
          pipeout=pipeout,
          selection=tools.selBest,
          replacement=random.sample,
      )
  
      MU = 300
      NGEN = 40
      CXPB = 0.5
      MUTPB = 0.2
      MIG_RATE = 5
  
      deme = toolbox.population(n=MU)
      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",
          "deme",
          "evals",
          "std",
          "min",
          "avg",
          "max",
      )
  
      for ind in deme:
          ind.fitness.values = toolbox.evaluate(ind)
      record = stats.compile(deme)
      logbook.record(gen=0, deme=procid, evals=len(deme), **record)
      hof.update(deme)
  
      if procid == 0:
          # Synchronization needed to log header on top and only once
          print(logbook.stream)
          sync.set()
      else:
          logbook.log_header = False  # Never output the header
          sync.wait()
          print(logbook.stream)
  
      for gen in range(1, NGEN):
          deme = toolbox.select(deme, len(deme))
          deme = algorithms.varAnd(
              deme, toolbox, cxpb=CXPB, mutpb=MUTPB
          )
  
          invalid_ind = [ind for ind in deme if not ind.fitness.valid]
          for ind in invalid_ind:
              ind.fitness.values = toolbox.evaluate(ind)
  
          hof.update(deme)
          record = stats.compile(deme)
          logbook.record(
              gen=gen, deme=procid, evals=len(deme), **record
          )
          print(logbook.stream)
  
          if gen % MIG_RATE == 0 and gen > 0:
              toolbox.migrate(deme)
  
file_path: deap/examples/ga/onemax_island.py
imports: import array
  import random
  import numpy
  from collections import deque
  from multiprocessing import Event, Pipe, Process
  from deap import algorithms
  from deap import base
  from deap import creator
  from deap import tools
label_desc: Use image node_id 3 for calling a global function with example usage: main(procid, pipein, pipeout, sync, seed) without return types