code: def plot_intermediate_values(study: Study) -> "Axes":
      """Plot intermediate values of all trials in a study with Matplotlib.
  
      .. note::
          Please refer to `matplotlib.pyplot.legend
          <https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html>`_
          to adjust the style of the generated legend.
  
      Example:
  
          The following code snippet shows how to plot intermediate values.
  
          .. plot::
  
              import optuna
  
  
              def f(x):
                  return (x - 2) ** 2
  
  
              def df(x):
                  return 2 * x - 4
  
  
              def objective(trial):
                  lr = trial.suggest_float("lr", 1e-5, 1e-1, log=True)
  
                  x = 3
                  for step in range(128):
                      y = f(x)
  
                      trial.report(y, step=step)
                      if trial.should_prune():
                          raise optuna.TrialPruned()
  
                      gy = df(x)
                      x -= gy * lr
  
                  return y
  
  
              sampler = optuna.samplers.TPESampler(seed=10)
              study = optuna.create_study(sampler=sampler)
              study.optimize(objective, n_trials=16)
  
              optuna.visualization.matplotlib.plot_intermediate_values(study)
  
      .. seealso::
          Please refer to :func:`optuna.visualization.plot_intermediate_values` for an example.
  
      Args:
          study:
              A :class:`~optuna.study.Study` object whose trials are plotted for their intermediate
              values.
  
      Returns:
          A :class:`matplotlib.axes.Axes` object.
      """
  
      _imports.check()
      return _get_intermediate_plot(_get_intermediate_plot_info(study))
  
file_path: optuna/optuna/visualization/matplotlib/_intermediate_values.py
imports: from optuna._experimental import experimental_func
  from optuna.logging import get_logger
  from optuna.study import Study
  from optuna.visualization._intermediate_values import _get_intermediate_plot_info
  from optuna.visualization._intermediate_values import _IntermediatePlotInfo
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 1 for calling a global function with example usage: plot_intermediate_values(study) and returns: _get_intermediate_plot