code: def _filter_inf(population: list[FrozenTrial]) -> np.ndarray:
      # Collect all objective values.
      n_objectives = len(population[0].values)
      objective_matrix = np.zeros((len(population), n_objectives))
      for i, trial in enumerate(population):
          objective_matrix[i] = np.array(trial.values, dtype=float)
  
      mask_posinf = np.isposinf(objective_matrix)
      mask_neginf = np.isneginf(objective_matrix)
  
      # Replace +-inf with nan temporary to get max and min.
      objective_matrix[mask_posinf + mask_neginf] = np.nan
      nadir_point = np.nanmax(objective_matrix, axis=0)
      ideal_point = np.nanmin(objective_matrix, axis=0)
      interval = nadir_point - ideal_point
  
      # TODO(Shinichi) reconsider alternative value for inf.
      rows_posinf, cols_posinf = np.where(mask_posinf)
      objective_matrix[rows_posinf, cols_posinf] = (
          nadir_point[cols_posinf] + _COEF * interval[cols_posinf]
      )
      rows_neginf, cols_neginf = np.where(mask_neginf)
      objective_matrix[rows_neginf, cols_neginf] = (
          ideal_point[cols_neginf] - _COEF * interval[cols_neginf]
      )
  
      return objective_matrix
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Callable
  from collections.abc import Sequence
  import itertools
  import math
  import numpy
  from optuna.samplers._lazy_random_state import LazyRandomState
  from optuna.samplers.nsgaii._dominates import _constrained_dominates
  from optuna.samplers.nsgaii._dominates import _validate_constraints
  from optuna.samplers.nsgaii._elite_population_selection_strategy import _fast_non_dominated_sort
  from optuna.study import Study
  from optuna.study._multi_objective import _dominates
  from optuna.trial import FrozenTrial
label_desc: Use image node_id 3 for calling a global function with example usage: _filter_inf(population) and returns: objective_matrix