code: def addCompare(optimizer: Optimizer) -> None:
      def compare(
          self: Optimizer,
          winners: tp.List[p.Parameter],
          losers: tp.List[p.Parameter],
      ) -> None:
          # This means that for any i and j, winners[i] is better than winners[i+1], and better than losers[j].
          # This is for cases in which we do not know fitness values, we just know comparisons.
  
          ref = self.parametrization
          # Evaluate the best fitness value among losers.
          best_fitness_value = 0.0
          for candidate in losers:
              data = candidate.get_standardized_data(
                  reference=self.parametrization
              )
              if data in self.archive:
                  best_fitness_value = min(
                      best_fitness_value,
                      self.archive[data].get_estimation("average"),
                  )
  
          # Now let us decide the fitness value of winners.
          for i, candidate in enumerate(winners):
              self.tell(
                  candidate, best_fitness_value - len(winners) + i
              )
              data = candidate.get_standardized_data(
                  reference=self.parametrization
              )
              self.archive[data] = utils.MultiValue(
                  candidate,
                  best_fitness_value - len(winners) + i,
                  reference=ref,
              )
  
      setattr(optimizer.__class__, "compare", compare)
  
imports: import pickle
  import warnings
  from pathlib import Path
  from numbers import Real
  from collections import deque
  import numpy
  import nevergrad.common.typing
  from nevergrad.parametrization import parameter
  from nevergrad.common import tools
  from nevergrad.common import errors
  from nevergrad.common.decorators import Registry
  from .None import utils
  from .None import multiobjective
label_desc: Use image node_id 3 for calling a global function with example usage: addCompare(optimizer) without return types