code: def test_calculate_weights_below_for_multi_objective() -> None:
      # No sample.
      study = optuna.create_study(directions=["minimize", "minimize"])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study, [], None
          )
      )
      assert len(weights_below) == 0
  
      # One sample.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[0.2, 0.5])
      study.add_trials([trial0])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study, [trial0], None
          )
      )
      assert len(weights_below) == 1
      assert sum(weights_below) > 0
  
      # Two samples.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[0.2, 0.5])
      trial1 = optuna.create_trial(values=[0.9, 0.4])
      study.add_trials([trial0, trial1])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1],
              None,
          )
      )
      assert len(weights_below) == 2
      assert weights_below[0] > weights_below[1]
      assert sum(weights_below) > 0
  
      # Two equally contributed samples.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[0.2, 0.8])
      trial1 = optuna.create_trial(values=[0.8, 0.2])
      study.add_trials([trial0, trial1])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1],
              None,
          )
      )
      assert len(weights_below) == 2
      assert weights_below[0] == weights_below[1]
      assert sum(weights_below) > 0
  
      # Duplicated samples.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[0.2, 0.8])
      trial1 = optuna.create_trial(values=[0.2, 0.8])
      study.add_trials([trial0, trial1])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1],
              None,
          )
      )
      assert len(weights_below) == 2
      assert weights_below[0] == weights_below[1]
      assert sum(weights_below) > 0
  
      # Three samples.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[0.3, 0.3])
      trial1 = optuna.create_trial(values=[0.2, 0.8])
      trial2 = optuna.create_trial(values=[0.8, 0.2])
      study.add_trials([trial0, trial1, trial2])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1, trial2],
              None,
          )
      )
      assert len(weights_below) == 3
      assert weights_below[0] > weights_below[1]
      assert weights_below[0] > weights_below[2]
      assert weights_below[1] == weights_below[2]
      assert sum(weights_below) > 0
  
      # Zero/negative objective values.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(values=[-0.3, -0.3])
      trial1 = optuna.create_trial(values=[0.0, -0.8])
      trial2 = optuna.create_trial(values=[-0.8, 0.0])
      study.add_trials([trial0, trial1, trial2])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1, trial2],
              None,
          )
      )
      assert len(weights_below) == 3
      assert weights_below[0] > weights_below[1]
      assert weights_below[0] > weights_below[2]
      assert np.isclose(weights_below[1], weights_below[2])
      assert sum(weights_below) > 0
  
      # +/-inf objective values.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(
          values=[-float("inf"), -float("inf")]
      )
      trial1 = optuna.create_trial(values=[0.0, -float("inf")])
      trial2 = optuna.create_trial(values=[-float("inf"), 0.0])
      study.add_trials([trial0, trial1, trial2])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1, trial2],
              None,
          )
      )
      assert len(weights_below) == 3
      assert all([np.isnan(w) for w in weights_below])
  
      # Three samples with two infeasible trials.
      study = optuna.create_study(directions=["minimize", "minimize"])
      trial0 = optuna.create_trial(
          values=[0.3, 0.3], system_attrs={"constraints": 2}
      )
      trial1 = optuna.create_trial(
          values=[0.2, 0.8], system_attrs={"constraints": 8}
      )
      trial2 = optuna.create_trial(
          values=[0.8, 0.2], system_attrs={"constraints": 0}
      )
      study.add_trials([trial0, trial1, trial2])
      weights_below = (
          _tpe.sampler._calculate_weights_below_for_multi_objective(
              study,
              [trial0, trial1, trial2],
              lambda trial: [trial.system_attrs["constraints"]],
          )
      )
      assert len(weights_below) == 3
      assert weights_below[0] == _tpe.sampler.EPS
      assert weights_below[1] == _tpe.sampler.EPS
      assert weights_below[2] > 0
  
imports: import random
  from typing import Callable
  from typing import Dict
  from typing import List
  from typing import Optional
  from typing import Union
  from unittest.mock import patch
  from unittest.mock import PropertyMock
  import numpy
  import pytest
  import optuna
  from optuna.samplers import _tpe
  from optuna.samplers import TPESampler
label_desc: Use image node_id 14 for calling a global function with example usage: test_calculate_weights_below_for_multi_objective() without return types