code: def _get_imputed_data(
      pipeline: ForecastingPipeline,
      y: pd.Series,
      X: Optional[pd.DataFrame] = None,
  ) -> Tuple[pd.Series, Optional[pd.DataFrame]]:
      """Passes y and X through the pipeline and returns the imputed data.
  
      Assumption
      ----------
      If imputer is present in the pipeline, then it must be the first step.
      This check is done at the time the pipeline is created and is not repeated
      here. Also, note that the user may append a custom imputer after the first
      step as well. This is fine as long as the first step is an Imputer.
      This function will only return the output of the Imputer in the first step.
  
      Parameters
      ----------
      pipeline : ForecastingPipeline
          The pipeline used to get the imputed values
      y : pd.Series
          target data to be used for imputation
      X : pd.DataFrame, optional
          Exogenous variable data to be used for imputation, by default None
  
      Reminder: The pipeline structure is as follows:
      ForecastingPipeline
          - TransformerPipeline(exogenous_steps) [Optional]
          - TransformedTargetForecaster
              - TransformerPipeline(target_steps) [Optional]
              - model
  
      Returns
      -------
      Tuple[pd.Series, Optional[pd.DataFrame]]
          Imputed y and X values respectively
      """
      # Since we are fitting (fit_transform) with new data, need to make sure
      # we do not have side effects on pipeline
      pipeline_ = deepcopy(pipeline)
  
      if X is None:
          # No exogenous variables
          # Note: fit_transform does not work when X is None
          X_imputed = None
      else:
          # Exogenous variables present
          X_imputed = X.copy()
  
          if _transformations_present_X(pipeline_):
              transformer_pipeline_X = pipeline_.steps_[0][1]
              for _, transformer_X in transformer_pipeline_X.steps_:
                  if isinstance(transformer_X, Imputer):
                      X_imputed = transformer_X.fit_transform(X, y)
                      continue
  
      y_imputed = y.copy()
      if _transformations_present_y(pipeline_):
          transformer_pipeline_y = pipeline_.steps_[-1][1].steps_[0][1]
          for _, transformer_y in transformer_pipeline_y.steps_:
              if isinstance(transformer_y, Imputer):
                  y_imputed = transformer_y.fit_transform(y)
                  continue
  
      return y_imputed, X_imputed
  
file_path: pycaret/pycaret/utils/time_series/forecasting/pipeline.py
imports: from copy import deepcopy
  from typing import Optional, Tuple
  import pandas
  from sktime.forecasting.base import BaseForecaster
  from sktime.forecasting.compose import ForecastingPipeline
  from sktime.transformations.compose import TransformerPipeline
  from sktime.transformations.series.impute import Imputer
label_desc: Use image node_id 5 for calling a global function with example usage: _get_imputed_data(pipeline, y, X) and returns: y_imputed,  X_imputed