code: def _reshape_raw_predictions_to_forecst_df(
      df: pd.DataFrame,
      predicted: np.ndarray,
      components: Optional[Components],
      prediction_frequency: Optional[dict],
      dates: pd.Series,
      n_forecasts: int,
      max_lags: int,
      freq: Optional[str],
      quantiles: List[float],
      config_lagged_regressors: Optional[ConfigLaggedRegressors],
  ) -> pd.DataFrame:
      """
      Turns forecast-origin-wise predictions into forecast-target-wise predictions.
  
      Parameters
      ----------
          df : pd.DataFrame
              input dataframe
          predicted : np.array
              Array containing the forecasts
          components : dict[np.array]
              Dictionary of components containing an array of each components' contribution to the forecast
          prediction_frequency : str
              Frequency of the predictions
          dates : pd.Series
              timestamps referring to the start of the predictions
          n_forecasts : int
              Number of steps ahead of prediction time step to forecast.
          max_lags : int
              Maximum number of lags to use
          freq : str
              Data step sizes. Frequency of data recording.
          quantiles : list[float]
              List of quantiles to include in the forecast
          config_lagged_regressors : ConfigLaggedRegressors
              Configuration for lagged regressors
  
      Returns
      -------
          pd.DataFrame
              columns ``ds``, ``y``, ``trend`` and [``yhat<i>``]
  
              Note
              ----
              where yhat<i> refers to the i-step-ahead prediction for this row's datetime.
              e.g. yhat3 is the prediction for this datetime, predicted 3 steps ago, "3 steps old".
      """
      # Receives df with single ID column
      assert len(df["ID"].unique()) == 1
      cols = ["ds", "y", "ID"]  # cols to keep from df
      df_forecast = pd.concat((df[cols],), axis=1)
      # create a line for each forecast_lag
      # 'yhat<i>' is the forecast for 'y' at 'ds' from i steps ago.
      for j in range(len(quantiles)):
          for forecast_lag in range(1, n_forecasts + 1):
              forecast = predicted[:, forecast_lag - 1, j]
              pad_before = max_lags + forecast_lag - 1
              pad_after = n_forecasts - forecast_lag
              yhat = np.pad(
                  forecast,
                  (pad_before, pad_after),
                  mode="constant",
                  constant_values=np.NaN,
              )
              if prediction_frequency is not None:
                  ds = df_forecast["ds"].iloc[
                      pad_before : -pad_after if pad_after > 0 else None
                  ]
                  mask = df_utils.create_mask_for_prediction_frequency(
                      prediction_frequency=prediction_frequency,
                      ds=ds,
                      forecast_lag=forecast_lag,
                  )
                  yhat = np.full((len(ds),), np.nan)
                  yhat[mask] = forecast
                  yhat = np.pad(
                      yhat,
                      (pad_before, pad_after),
                      mode="constant",
                      constant_values=np.NaN,
                  )
              # 0 is the median quantile index
              if j == 0:
                  name = f"yhat{forecast_lag}"
              else:
                  name = f"yhat{forecast_lag} {round(quantiles[j] * 100, 1)}%"
              df_forecast[name] = yhat
  
      if components is None:
          return df_forecast
  
      # else add components
      lagged_components = [
          "ar",
      ]
      if config_lagged_regressors is not None:
          for name in config_lagged_regressors.keys():
              lagged_components.append(f"lagged_regressor_{name}")
      for comp in lagged_components:
          if comp in components:
              for j in range(len(quantiles)):
                  for forecast_lag in range(1, n_forecasts + 1):
                      forecast = components[comp][
                          :, forecast_lag - 1, j
                      ]  # 0 is the median quantile
                      pad_before = max_lags + forecast_lag - 1
                      pad_after = n_forecasts - forecast_lag
                      yhat = np.pad(
                          forecast,
                          (pad_before, pad_after),
                          mode="constant",
                          constant_values=np.NaN,
                      )
                      if prediction_frequency is not None:
                          ds = df_forecast["ds"].iloc[
                              pad_before : -pad_after
                              if pad_after > 0
                              else None
                          ]
                          mask = df_utils.create_mask_for_prediction_frequency(
                              prediction_frequency=prediction_frequency,
                              ds=ds,
                              forecast_lag=forecast_lag,
                          )
                          yhat = np.full((len(ds),), np.nan)
                          yhat[mask] = forecast
                          yhat = np.pad(
                              yhat,
                              (pad_before, pad_after),
                              mode="constant",
                              constant_values=np.NaN,
                          )
                      if (
                          j == 0
                      ):  # temporary condition to add only the median component
                          name = f"{comp}{forecast_lag}"
                          df_forecast[name] = yhat
  
      # only for non-lagged components
      for comp in components:
          if comp not in lagged_components:
              for j in range(len(quantiles)):
                  forecast_0 = components[comp][0, :, j]
                  forecast_rest = components[comp][
                      1:, n_forecasts - 1, j
                  ]
                  yhat = np.pad(
                      np.concatenate((forecast_0, forecast_rest)),
                      (max_lags, 0),
                      mode="constant",
                      constant_values=np.NaN,
                  )
                  if prediction_frequency is not None:
                      date_list = []
                      for key, value in prediction_frequency.items():
                          if key == "daily-hour":
                              dates_comp = dates[dates.dt.hour == value]
                          elif key == "weekly-day":
                              dates_comp = dates[
                                  dates.dt.dayofweek == value
                              ]
                          elif key == "monthly-day":
                              dates_comp = dates[dates.dt.day == value]
                          elif key == "yearly-month":
                              dates_comp = dates[
                                  dates.dt.month == value
                              ]
                          elif key == "hourly-minute":
                              dates_comp = dates[
                                  dates.dt.minute == value
                              ]
                          else:
                              raise ValueError(
                                  f"prediction_frequency {key} not supported"
                              )
                          date_list.append(dates_comp)
                      # create new pd.Series only containing the dates that are in all Series in date_list
                      dates_comp = pd.Series(date_list[0])
                      for i in range(1, len(date_list)):
                          dates_comp = dates_comp[
                              dates_comp.isin(date_list[i])
                          ]
                      ser = pd.Series(dtype="datetime64[ns]")
                      for date in dates_comp:
                          d = pd.date_range(
                              date, periods=n_forecasts + 1, freq=freq
                          )
                          ser = pd.concat((ser, pd.Series(d).iloc[1:]))
                      df_comp = pd.DataFrame(
                          {
                              "ds": ser,
                              "yhat": components[comp][
                                  :, :, j
                              ].flatten(),
                          }
                      ).drop_duplicates(subset="ds")
                      df_comp, _ = df_utils.add_missing_dates_nan(
                          df=df_comp, freq=freq
                      )
                      yhat = pd.merge(
                          df_forecast.filter(["ds", "ID"]),
                          df_comp,
                          on="ds",
                          how="left",
                      )["yhat"].values
                  if (
                      j == 0
                  ):  # temporary condition to add only the median component
                      # add yhat into dataframe, using df_forecast indexing
                      yhat_df = pd.Series(yhat, name=comp).set_axis(
                          df_forecast.index
                      )
                      df_forecast = pd.concat(
                          [df_forecast, yhat_df],
                          axis=1,
                          ignore_index=False,
                      )
      return df_forecast
  
file_path: neural_prophet/neuralprophet/data/process.py
imports: import logging
  from typing import List, Optional
  import numpy
  import pandas
  from neuralprophet import df_utils, time_dataset
  from neuralprophet.configure import ConfigCountryHolidays, ConfigEvents, ConfigFutureRegressors, ConfigLaggedRegressors, ConfigSeasonality
  from neuralprophet.np_types import Components
label_desc: Use image node_id 1 for calling a global function with example usage: _reshape_raw_predictions_to_forecst_df(df, predicted, components, prediction_frequency, dates, n_forecasts, max_lags, freq, quantiles, config_lagged_regressors) and returns: df_forecast, df_forecast