docstr: Transforms series back to high frequency by retrieving the original high frequency and reshaping the values.
  
  When converting to/from anchorable offset [1]_, the index is rolled backward if the series does not start on
  the anchor date to preserve all the values.
  
  Steps:
      (1) Reshape the values to flatten the components introduced by the transform
      (2) Eliminate the rows filled with NaNs, to facilitate time index adjustment
      (3) Retrieve the original components name
      (4) When applicable, shift the time index start back in time
      (5) Generate a new time index with the high frequency
  
  References
  ----------
  .. [1] https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#anchored-offsets
docstr_tok: ["Transforms","series","back","to","high","frequency","by","retrieving","the","original","high","frequency","and","reshaping","the","values",".","When","converting","to\/from","anchorable","offset","[","1","]","_",",","the","index","is","rolled","backward","if","the","series","does","not","start","on","the","anchor","date","to","preserve","all","the","values",".","Steps",":","(","1",")","Reshape","the","values","to","flatten","the","components","introduced","by","the","transform","(","2",")","Eliminate","the","rows","filled","with","NaNs",",","to","facilitate","time","index","adjustment","(","3",")","Retrieve","the","original","components","name","(","4",")","When","applicable",",","shift","the","time","index","start","back","in","time","(","5",")","Generate","a","new","time","index","with","the","high","frequency","References","--","--","--","--","--","..","[","1","]","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","anchored-offsets"]
code: def ts_inverse_transform(
      series: TimeSeries,
      params: Mapping[str, Any],
  ) -> TimeSeries:
      """
      Transforms series back to high frequency by retrieving the original high frequency and reshaping the values.
  
      When converting to/from anchorable offset [1]_, the index is rolled backward if the series does not start on
      the anchor date to preserve all the values.
  
      Steps:
          (1) Reshape the values to flatten the components introduced by the transform
          (2) Eliminate the rows filled with NaNs, to facilitate time index adjustment
          (3) Retrieve the original components name
          (4) When applicable, shift the time index start back in time
          (5) Generate a new time index with the high frequency
  
      References
      ----------
      .. [1] https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#anchored-offsets
      """
      low_freq = params["fixed"]["_low_freq"]
      drop_static_covariates = params["fixed"][
          "_drop_static_covariates"
      ]
      feature_sep = params["fixed"]["_sep"]
      high_freq = params["fitted"]["high_freq"]
      orig_ts_start_time = params["fitted"]["start"]
      orig_ts_end_time = params["fitted"]["end"]
      MIDAS._verify_series(series, low_freq=low_freq)
  
      # retrieve the number of component introduced by midas
      n_midas_components = (
          int(series.components[-1].split(feature_sep)[-1]) + 1
      )
      series_n_components = series.n_components
  
      n_orig_components = series_n_components // n_midas_components
  
      if len(series) == 0:
          # placeholders for empty series
          start_time = pd.Timestamp("2020-01-01")
          shift = 0
          series_values = np.empty(
              (0, n_orig_components, series.n_samples)
          )
      else:
          series_values = series.all_values(copy=False).reshape(
              -1, n_orig_components, series.n_samples
          )
  
          # remove the rows containing only NaNs at the extremities of the array, necessary to adjust the time index
          first_finite_row, last_finite_row = _finite_rows_boundaries(
              series_values, how="all"
          )
          # adding one to make the end bound inclusive
          series_values = series_values[
              first_finite_row : last_finite_row + 1
          ]
  
          start_time = series.start_time()
          shift = 0
          # adjust the start if was shifted due to the frequency change
          if len(series.time_index) > 1:
              low_freq_timedelta = (
                  series.time_index[1] - series.time_index[0]
              )
              start_to_start_shift = (
                  series.time_index[0] - orig_ts_start_time
              )
              start_to_end_shift = (
                  series.time_index[0] - orig_ts_end_time
              )
              # shift is caused by the low frequency anchoring, fitted and inversed ts have the same start
              if np.abs(start_to_start_shift) <= low_freq_timedelta:
                  start_time = orig_ts_start_time
              # shift is caused by the low frequency anchoring, inversed ts starts after the end of the fitted ts
              elif (
                  pd.Timedelta(0)
                  < start_to_end_shift
                  <= low_freq_timedelta
              ):
                  start_time = orig_ts_end_time
                  shift = 1
  
      time_index = generate_index(
          start=start_time,
          length=len(series_values) + shift,
          freq=high_freq,
          name=series.time_index.name,
      )[shift:]
  
      inversed_midas_ts = MIDAS._create_midas_df(
          series=series,
          arr=series_values,
          time_index=time_index,
          n_midas=n_midas_components,
          drop_static_covariates=drop_static_covariates,
          inverse_transform=True,
          feature_sep=feature_sep,
      )
      return inversed_midas_ts
  
file_path: darts/darts/dataprocessing/transformers/midas.py
imports: from typing import Any, Dict, List, Mapping, Optional, Sequence, Union
  import numpy
  import pandas
  from darts import TimeSeries
  from darts.dataprocessing.transformers import FittableDataTransformer, InvertibleDataTransformer
  from darts.logging import get_logger, raise_log
  from darts.timeseries import _finite_rows_boundaries
  from darts.utils.timeseries_generation import generate_index
label_desc: Use image node_id 4 for calling the MIDAS obj's underlying member method code with example usage: obj.ts_inverse_transform(series, params) and returns: inversed_midas_ts