code: def test_results_opt_best_output__bayesian_search_optuna_multiseries_with_output_study_best_trial_optuna():
      """
      Test results_opt_best output of _bayesian_search_optuna_multiseries with output
      study.best_trial optuna (mocked done in skforecast v0.12.0).
      """
      forecaster = ForecasterAutoregMultiSeries(
          regressor=Ridge(random_state=123), lags=2
      )
  
      steps = 3
      metric = "mean_absolute_error"
      n_validation = 12
      initial_train_size = len(series) - n_validation
      fixed_train_size = True
      refit = True
      verbose = False
      show_progress = False
  
      n_trials = 10
      random_state = 123
  
      def objective(
          trial,
          forecaster=forecaster,
          series=series,
          steps=steps,
          metric=metric,
          initial_train_size=initial_train_size,
          fixed_train_size=fixed_train_size,
          refit=refit,
          verbose=verbose,
          show_progress=show_progress,
      ) -> float:
          alpha = trial.suggest_float("alpha", 1e-2, 1.0)
  
          forecaster = ForecasterAutoregMultiSeries(
              regressor=Ridge(random_state=random_state, alpha=alpha),
              lags=2,
          )
  
          metrics_levels, _ = backtesting_forecaster_multiseries(
              forecaster=forecaster,
              series=series,
              steps=steps,
              metric=metric,
              initial_train_size=initial_train_size,
              fixed_train_size=fixed_train_size,
              refit=refit,
              verbose=verbose,
              show_progress=show_progress,
          )
  
          return abs(metrics_levels.iloc[:, 1].mean())
  
      study = optuna.create_study(
          direction="minimize", sampler=TPESampler(seed=random_state)
      )
      study.optimize(objective, n_trials=n_trials)
  
      best_trial = study.best_trial
  
      lags_grid = [2]
  
      def search_space(trial):
          search_space = {
              "alpha": trial.suggest_float("alpha", 1e-2, 1.0)
          }
  
          return search_space
  
      return_best = False
  
      results_opt_best = _bayesian_search_optuna_multiseries(
          forecaster=forecaster,
          series=series,
          lags_grid=lags_grid,
          search_space=search_space,
          steps=steps,
          metric=metric,
          refit=refit,
          initial_train_size=initial_train_size,
          fixed_train_size=fixed_train_size,
          n_trials=n_trials,
          return_best=return_best,
          verbose=verbose,
          show_progress=show_progress,
      )[1]
  
      assert best_trial.number == results_opt_best.number
      assert best_trial.values == results_opt_best.values
      assert best_trial.params == results_opt_best.params
  
imports: import re
  import pytest
  import numpy
  import pandas
  import sys
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.linear_model import Ridge
  from sklearn.metrics import mean_absolute_error
  from skforecast.ForecasterAutoregMultiSeries import ForecasterAutoregMultiSeries
  from skforecast.ForecasterAutoregMultiSeriesCustom import ForecasterAutoregMultiSeriesCustom
  from skforecast.model_selection_multiseries import backtesting_forecaster_multiseries
  from skforecast.model_selection_multiseries.model_selection_multiseries import _bayesian_search_optuna_multiseries
  import optuna
  from optuna.samplers import TPESampler
  from tqdm import tqdm
  from functools import partialmethod
  from .fixtures_model_selection_multiseries import series
label_desc: Use image node_id 13 for calling a global function with example usage: test_results_opt_best_output__bayesian_search_optuna_multiseries_with_output_study_best_trial_optuna() and returns: abs, search_space