class_docstr: This class implements the calculation of crowding distance for NSGA-II.
docstr: This function assigns the crowding distance to the solutions.
  :param front: The list of solutions.
code: def compute_distance(self, front: tp.List[p.Parameter]):
      """This function assigns the crowding distance to the solutions.
      :param front: The list of solutions.
      """
      size = len(front)
  
      if size == 0:
          return
      # The boundary solutions (solutions with smallest and largest function values)
      # are set to an infinite (maximum) distance value
      if size == 1:
          front[0]._meta["crowding_distance"] = float("inf")
          return
      if size == 2:
          front[0]._meta["crowding_distance"] = float("inf")
          front[1]._meta["crowding_distance"] = float("inf")
          return
  
      for f in front:
          f._meta["crowding_distance"] = 0.0
  
      if (
          isinstance(front[0].losses, np.ndarray)
          and front[0].losses.shape != ()
      ):
          number_of_objectives = len(front[0].losses)
      else:
          number_of_objectives = 1
  
      for i in range(number_of_objectives):
          self.accumulate_distance_per_objective(front, i)
  
file_path: nevergrad/nevergrad/optimization/multiobjective/nsga2.py
imports: import logging
  import numpy
  import nevergrad.common.typing
  from nevergrad.parametrization import parameter
label_desc: Use image node_id 2 for calling the CrowdingDistance obj's underlying member method code with example usage: obj.compute_distance(front) without return types