code: def test_nsga2(setup_teardown_multi_obj):
      NDIM = 5
      BOUND_LOW, BOUND_UP = 0.0, 1.0
      MU = 16
      NGEN = 100
  
      toolbox = base.Toolbox()
      toolbox.register(
          "attr_float", random.uniform, BOUND_LOW, BOUND_UP
      )
      toolbox.register(
          "individual",
          tools.initRepeat,
          creator.__dict__[INDCLSNAME],
          toolbox.attr_float,
          NDIM,
      )
      toolbox.register(
          "population", tools.initRepeat, list, toolbox.individual
      )
  
      toolbox.register("evaluate", benchmarks.zdt1)
      toolbox.register(
          "mate",
          tools.cxSimulatedBinaryBounded,
          low=BOUND_LOW,
          up=BOUND_UP,
          eta=20.0,
      )
      toolbox.register(
          "mutate",
          tools.mutPolynomialBounded,
          low=BOUND_LOW,
          up=BOUND_UP,
          eta=20.0,
          indpb=1.0 / NDIM,
      )
      toolbox.register("select", tools.selNSGA2)
  
      pop = toolbox.population(n=MU)
      fitnesses = toolbox.map(toolbox.evaluate, pop)
      for ind, fit in zip(pop, fitnesses):
          ind.fitness.values = fit
  
      pop = toolbox.select(pop, len(pop))
      for gen in range(1, NGEN):
          offspring = tools.selTournamentDCD(pop, len(pop))
          offspring = [toolbox.clone(ind) for ind in offspring]
  
          for ind1, ind2 in zip(offspring[::2], offspring[1::2]):
              if random.random() <= 0.9:
                  toolbox.mate(ind1, ind2)
  
              toolbox.mutate(ind1)
              toolbox.mutate(ind2)
              del ind1.fitness.values, ind2.fitness.values
  
          invalid_ind = [
              ind for ind in offspring if not ind.fitness.valid
          ]
          fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
          for ind, fit in zip(invalid_ind, fitnesses):
              ind.fitness.values = fit
  
          pop = toolbox.select(pop + offspring, MU)
  
      hv = hypervolume(pop, [11.0, 11.0])
      # hv = 120.777 # Optimal value
  
      assert (
          hv > HV_THRESHOLD
      ), "Hypervolume is lower than expected %f < %f" % (
          hv,
          HV_THRESHOLD,
      )
  
      for ind in pop:
          assert not (
              any(numpy.asarray(ind) < BOUND_LOW)
              or any(numpy.asarray(ind) > BOUND_UP)
          )
  
file_path: deap/tests/test_algorithms.py
imports: import random
  import numpy
  import pytest
  from deap import algorithms
  from deap import base
  from deap import benchmarks
  from deap.benchmarks.tools import hypervolume
  from deap import cma
  from deap import creator
  from deap import tools
label_desc: Use image node_id 6 for calling a global function with example usage: test_nsga2(setup_teardown_multi_obj) without return types