code: def test_optionalpassthrough():
      """Test for OptionalPassthrough used within grid search and with pipeline.
  
      Same as docstring example of OptionalPassthrough.
      """
      from sklearn.preprocessing import StandardScaler
  
      from sktime.datasets import load_airline
      from sktime.forecasting.compose import TransformedTargetForecaster
      from sktime.forecasting.model_selection import (
          ForecastingGridSearchCV,
      )
      from sktime.forecasting.naive import NaiveForecaster
      from sktime.split import SlidingWindowSplitter
      from sktime.transformations.series.adapt import (
          TabularToSeriesAdaptor,
      )
      from sktime.transformations.series.detrend import Deseasonalizer
  
      # create pipeline
      pipe = TransformedTargetForecaster(
          steps=[
              ("deseasonalizer", OptionalPassthrough(Deseasonalizer())),
              (
                  "scaler",
                  OptionalPassthrough(
                      TabularToSeriesAdaptor(StandardScaler())
                  ),
              ),
              ("forecaster", NaiveForecaster()),
          ]
      )
      # putting it all together in a grid search
      cv = SlidingWindowSplitter(
          initial_window=60,
          window_length=24,
          start_with_window=True,
          step_length=48,
      )
      param_grid = {
          "deseasonalizer__passthrough": [True, False],
          "scaler__transformer__transformer__with_mean": [True, False],
          "scaler__passthrough": [True, False],
          "forecaster__strategy": ["drift", "mean", "last"],
      }
      gscv = ForecastingGridSearchCV(
          forecaster=pipe, param_grid=param_grid, cv=cv, n_jobs=-1
      )
      gscv.fit(load_airline())
  
imports: import pytest
  from sktime.tests.test_switch import run_test_for_class
  from sktime.transformations.compose import OptionalPassthrough
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 1 for calling a global function with example usage: test_optionalpassthrough() without return types