code: def fcst_df_to_latest_forecast(fcst, quantiles, n_last=1):
      """Converts from line-per-lag to line-per-forecast.
  
      Parameters
      ----------
          fcst : pd.DataFrame
              Forecast df
          quantiles : list, default None
              A list of float values between (0, 1) which indicate the set of quantiles to be estimated.
          n_last : int
              Number of latest forecasts to include
  
      Returns
      -------
          pd.DataFrame
              Dataframe where origin-0 is latest forecast, origin-1 second to latest etc
      """
      cols = ["ds", "y"]  # cols to keep from df
      df = pd.concat((fcst[cols],), axis=1)
      df.reset_index(drop=True, inplace=True)
  
      yhat_col_names = [
          col_name
          for col_name in fcst.columns
          if "yhat" in col_name
          and "%" not in col_name
          and "qhat" not in col_name
      ]
      yhat_col_names_quants = [
          col_name
          for col_name in fcst.columns
          if "yhat" in col_name and "%" in col_name
      ]
      n_forecast_steps = len(yhat_col_names)
      yhats = pd.concat((fcst[yhat_col_names],), axis=1)
      yhats_quants = pd.concat((fcst[yhat_col_names_quants],), axis=1)
      cols = list(range(n_forecast_steps))
      for i in range(n_last - 1, -1, -1):
          forecast_name = f"origin-{i}"
          df[forecast_name] = None
          rows = len(df) + np.arange(-n_forecast_steps - i, -i, 1)
          last = yhats.values[rows, cols]
          df.loc[rows, forecast_name] = last
          startcol = 0
          endcol = n_forecast_steps
          for quantile_idx in range(1, len(quantiles)):
              yhats_quants_split = yhats_quants.iloc[
                  :, startcol:endcol
              ]  # split yhats_quants to consider one quantile at a time
              forecast_name_quants = "origin-{} {}%".format(
                  (i), quantiles[quantile_idx] * 100
              )
              df[forecast_name_quants] = None
              rows = len(df) + np.arange(-n_forecast_steps - i, -i, 1)
              last = yhats_quants_split.values[rows, cols]
              df.loc[rows, forecast_name_quants] = last
              startcol += n_forecast_steps
              endcol += n_forecast_steps
      return df
  
imports: from __future__ import annotations
  import logging
  import math
  import os
  import sys
  from collections import OrderedDict
  from typing import TYPE_CHECKING, Iterable, Optional, Union
  import numpy
  import pandas
  import pytorch_lightning
  import torch
  from neuralprophet import utils_torch
  from neuralprophet.hdays_utils import get_country_holidays
  from neuralprophet.logger import ProgressBar
label_desc: Use image node_id 19 for calling a global function with example usage: fcst_df_to_latest_forecast(fcst, quantiles, n_last) and returns: df