code: def test_filter_inf_trials_message(
      caplog: LogCaptureFixture, with_message: bool
  ) -> None:
      study = create_study()
      study.add_trial(
          create_trial(
              value=0.0,
              params={"x": 1.0},
              distributions={"x": FloatDistribution(0.0, 1.0)},
          )
      )
      study.add_trial(
          create_trial(
              value=float("inf"),
              params={"x": 0.0},
              distributions={"x": FloatDistribution(0.0, 1.0)},
          )
      )
  
      optuna.logging.enable_propagation()
      _filter_nonfinite(
          study.get_trials(states=(TrialState.COMPLETE,)),
          with_message=with_message,
      )
      msg = "Trial 1 is omitted in visualization because its objective value is inf or nan."
  
      if with_message:
          assert msg in caplog.text
          n_filtered_as_inf = 0
          for record in caplog.records:
              if record.msg == msg:
                  assert record.levelno == logging.WARNING
                  n_filtered_as_inf += 1
          assert n_filtered_as_inf == 1
      else:
          assert msg not in caplog.text
  
imports: import datetime
  import logging
  from textwrap import dedent
  from typing import cast
  import numpy
  import pytest
  from pytest import LogCaptureFixture
  import optuna
  from optuna.distributions import FloatDistribution
  from optuna.study import create_study
  from optuna.testing.visualization import prepare_study_with_trials
  from optuna.trial import create_trial
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
  from optuna.visualization import is_available
  from optuna.visualization._utils import _check_plot_args
  from optuna.visualization._utils import _filter_nonfinite
  from optuna.visualization._utils import _is_log_scale
  from optuna.visualization._utils import _make_hovertext
label_desc: Use image node_id 7 for calling a global function with example usage: test_filter_inf_trials_message(caplog, with_message) without return types