code: def _sklearn_reshape_apply(func, return_result, X, *args, **kwargs):
      """Reshape epochs and apply function."""
      if not isinstance(X, np.ndarray):
          raise ValueError(
              "data should be an np.ndarray, got %s." % type(X)
          )
      orig_shape = X.shape
      X = np.reshape(X.transpose(0, 2, 1), (-1, orig_shape[1]))
      X = func(X, *args, **kwargs)
      if return_result:
          X.shape = (orig_shape[0], orig_shape[2], orig_shape[1])
          X = X.transpose(0, 2, 1)
          return X
  
imports: import numpy
  from .._fiff.pick import _pick_data_channels, _picks_by_type, _picks_to_idx, pick_info, pick_types
  from ..cov import _check_scalings_user
  from ..filter import filter_data
  from ..time_frequency import psd_array_multitaper
  from ..utils import _check_option, _validate_type, fill_doc, verbose
  from .base import BaseEstimator
  from .mixin import TransformerMixin
label_desc: Use image node_id 1 for calling a global function with example usage: _sklearn_reshape_apply(func, return_result, X) and returns: X