docstr: Predict insample with core.NeuralForecast.
  
  `core.NeuralForecast`'s `predict_insample` uses stored fitted `models`
  to predict historic values of a time series from the stored dataframe.
  
  Parameters
  ----------
  step_size : int (default=1)
      Step size between each window.
  
  Returns
  -------
  fcsts_df : pandas.DataFrame
      DataFrame with insample predictions for all fitted `models`.
docstr_tok: ["Predict","insample","with","core.NeuralForecast",".","`","core.NeuralForecast","`","'s","`","predict_insample","`","uses","stored","fitted","`","models","`","to","predict","historic","values","of","a","time","series","from","the","stored","dataframe",".","Parameters","--","--","--","--","--","step_size",":","int","(","default=1",")","Step","size","between","each","window",".","Returns","--","--","--","-","fcsts_df",":","pandas.DataFrame","DataFrame","with","insample","predictions","for","all","fitted","`","models","`","."]
code: def predict_insample(self, step_size: int = 1):
      """Predict insample with core.NeuralForecast.
  
      `core.NeuralForecast`'s `predict_insample` uses stored fitted `models`
      to predict historic values of a time series from the stored dataframe.
  
      Parameters
      ----------
      step_size : int (default=1)
          Step size between each window.
  
      Returns
      -------
      fcsts_df : pandas.DataFrame
          DataFrame with insample predictions for all fitted `models`.
      """
      if not self._fitted:
          raise Exception(
              "The models must be fitted first with `fit` or `cross_validation`."
          )
  
      for model in self.models:
          if model.SAMPLING_TYPE == "recurrent":
              warnings.warn(
                  f"Predict insample might not provide accurate predictions for \
                         recurrent model {repr(model)} class yet due to scaling."
              )
              print(
                  f"WARNING: Predict insample might not provide accurate predictions for \
                        recurrent model {repr(model)} class yet due to scaling."
              )
  
      cols = []
      count_names = {"model": 0}
      for model in self.models:
          model_name = repr(model)
          count_names[model_name] = count_names.get(model_name, -1) + 1
          if count_names[model_name] > 0:
              model_name += str(count_names[model_name])
          cols += [model_name + n for n in model.loss.output_names]
  
      # Remove test set from dataset and last dates
      test_size = self.models[0].get_test_size()
      if test_size > 0:
          trimmed_dataset = TimeSeriesDataset.trim_dataset(
              dataset=self.dataset, right_trim=test_size, left_trim=0
          )
          new_idxs = np.hstack(
              [
                  np.arange(
                      self.dataset.indptr[i],
                      self.dataset.indptr[i + 1] - test_size,
                  )
                  for i in range(self.dataset.n_groups)
              ]
          )
          times = self.ds[new_idxs]
      else:
          trimmed_dataset = self.dataset
          times = self.ds
  
      # Generate dates
      fcsts_df = _insample_times(
          times=times,
          uids=self.uids,
          indptr=trimmed_dataset.indptr,
          h=self.h,
          freq=self.freq,
          step_size=step_size,
          id_col=self.id_col,
          time_col=self.time_col,
      )
  
      col_idx = 0
      fcsts = np.full(
          (len(fcsts_df), len(cols)), np.nan, dtype=np.float32
      )
  
      for model in self.models:
          # Test size is the number of periods to forecast (full size of trimmed dataset)
          model.set_test_size(test_size=trimmed_dataset.max_size)
  
          # Predict
          model_fcsts = model.predict(
              trimmed_dataset, step_size=step_size
          )
          # Append predictions in memory placeholder
          output_length = len(model.loss.output_names)
          fcsts[:, col_idx : (col_idx + output_length)] = model_fcsts
          col_idx += output_length
          model.set_test_size(
              test_size=test_size
          )  # Set original test_size
  
      # original y
      original_y = {
          self.id_col: ufp.repeat(
              self.uids, np.diff(self.dataset.indptr)
          ),
          self.time_col: self.ds,
          self.target_col: self.dataset.temporal[:, 0].numpy(),
      }
  
      # Add predictions to forecasts DataFrame
      if isinstance(self.uids, pl_Series):
          fcsts = pl_DataFrame(dict(zip(cols, fcsts.T)))
          Y_df = pl_DataFrame(original_y)
      else:
          fcsts = pd.DataFrame(fcsts, columns=cols)
          Y_df = pd.DataFrame(original_y).reset_index(drop=True)
      fcsts_df = ufp.horizontal_concat([fcsts_df, fcsts])
  
      # Add original input df's y to forecasts DataFrame
      fcsts_df = ufp.join(
          fcsts_df, Y_df, how="left", on=[self.id_col, self.time_col]
      )
      if self.scalers_:
          sizes = ufp.counts_by_id(fcsts_df, self.id_col)[
              "counts"
          ].to_numpy()
          indptr = np.append(0, sizes.cumsum())
          invert_cols = cols + [self.target_col]
          fcsts_df[
              invert_cols
          ] = self._scalers_target_inverse_transform(
              fcsts_df[invert_cols].to_numpy(), indptr
          )
      if isinstance(fcsts_df, pd.DataFrame) and _id_as_idx():
          _warn_id_as_idx()
          fcsts_df = fcsts_df.set_index(self.id_col)
      return fcsts_df
  
imports: import os
  import pickle
  import warnings
  from copy import deepcopy
  from itertools import chain
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  import torch
  import utilsforecast.processing
  from utilsforecast.compat import DataFrame, Series, pl_DataFrame, pl_Series
  from utilsforecast.grouped_array import GroupedArray
  from utilsforecast.target_transforms import BaseTargetTransform, LocalBoxCox, LocalMinMaxScaler, LocalRobustScaler, LocalStandardScaler
  from utilsforecast.validation import validate_freq
  from .tsdataset import TimeSeriesDataset
  from neuralforecast.models import GRU, LSTM, RNN, TCN, DeepAR, DilatedRNN, MLP, NHITS, NBEATS, NBEATSx, TFT, VanillaTransformer, Informer, Autoformer, FEDformer, StemGNN, PatchTST, TimesNet
label_desc: Use image node_id 14 for calling the NeuralForecast obj's underlying member method code with example usage: obj.predict_insample(step_size) and returns: fcsts_df