code: def test_results_output_bayesian_search_optuna_multiseries_with_mocked_when_kwargs_study_optimize():
      """
      Test output of _bayesian_search_optuna_multiseries in ForecasterAutoregMultiSeries
      when `kwargs_study_optimize` with mocked (mocked done in skforecast v0.12.0).
      """
      forecaster = ForecasterAutoregMultiSeries(
          regressor=RandomForestRegressor(random_state=123), lags=2
      )
  
      steps = 3
      n_validation = 12
      lags_grid = [2, 4]
  
      def search_space(trial):
          search_space = {
              "n_estimators": trial.suggest_int(
                  "n_estimators", 100, 200
              ),
              "max_depth": trial.suggest_int(
                  "max_depth", 20, 35, log=True
              ),
              "max_features": trial.suggest_categorical(
                  "max_features", ["log2", "sqrt"]
              ),
          }
  
          return search_space
  
      # kwargs_study_optimize
      timeout = 3.0
  
      results = _bayesian_search_optuna_multiseries(
          forecaster=forecaster,
          series=series,
          steps=steps,
          lags_grid=lags_grid,
          search_space=search_space,
          metric="mean_absolute_error",
          refit=False,
          initial_train_size=len(series) - n_validation,
          n_trials=10,
          random_state=123,
          n_jobs=1,
          return_best=False,
          verbose=False,
          kwargs_study_optimize={"timeout": timeout},
      )[0].reset_index(drop=True)
  
      expected_results = pd.DataFrame(
          {
              "levels": [["l1", "l2"]] * 2,
              "lags": [[1, 2], [1, 2]],
              "params": [
                  {
                      "n_estimators": 144,
                      "max_depth": 20,
                      "max_features": "sqrt",
                  },
                  {
                      "n_estimators": 143,
                      "max_depth": 33,
                      "max_features": "log2",
                  },
              ],
              "mean_absolute_error": np.array([0.18642719, 0.18984788]),
              "n_estimators": np.array([144, 143]),
              "max_depth": np.array([20, 33]),
              "max_features": ["sqrt", "log2"],
          },
          index=pd.Index([0, 1], dtype="int64"),
      )
  
      pd.testing.assert_frame_equal(
          results.head(1), expected_results.head(1), check_dtype=False
      )
  
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 8 for calling a global function with example usage: test_results_output_bayesian_search_optuna_multiseries_with_mocked_when_kwargs_study_optimize() and returns: search_space