class_docstr: Base Recurrent
  
  Base class for all recurrent-based models. The forecasts are produced sequentially between
  windows.
  
  This class implements the basic functionality for all windows-based models, including:
  - PyTorch Lightning's methods training_step, validation_step, predict_step. <br>
  - fit and predict methods used by NeuralForecast.core class. <br>
  - sampling and wrangling methods to sequential windows. <br>
class_docstr_tok: ["Base","Recurrent","Base","class","for","all","recurrent-based","models",".","The","forecasts","are","produced","sequentially","between","windows",".","This","class","implements","the","basic","functionality","for","all","windows-based","models",",","including",":","-","PyTorch","Lightning","'s","methods","training_step",",","validation_step",",","predict_step",".","<","br",">","-","fit","and","predict","methods","used","by","NeuralForecast.core","class",".","<","br",">","-","sampling","and","wrangling","methods","to","sequential","windows",".","<","br",">"]
docstr: Predict.
  
  Neural network prediction with PL's `Trainer` execution of `predict_step`.
  
  **Parameters:**<br>
  `dataset`: NeuralForecast's `TimeSeriesDataset`, see [documentation](https://nixtla.github.io/neuralforecast/tsdataset.html).<br>
  `step_size`: int=1, Step size between each window.<br>
  `random_seed`: int=None, random_seed for pytorch initializer and numpy generators, overwrites model.__init__'s.<br>
  `**data_module_kwargs`: PL's TimeSeriesDataModule args, see [documentation](https://pytorch-lightning.readthedocs.io/en/1.6.1/extensions/datamodules.html#using-a-datamodule).
docstr_tok: ["Predict",".","Neural","network","prediction","with","PL","'s","`","Trainer","`","execution","of","`","predict_step","`",".","*","*","Parameters",":","*","*","<","br",">","`","dataset","`",":","NeuralForecast","'s","`","TimeSeriesDataset","`",",","see","[","documentation","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/tsdataset.html",")",".","<","br",">","`","step_size","`",":","int=1",",","Step","size","between","each","window.","<","br",">","`","random_seed","`",":","int=None",",","random_seed","for","pytorch","initializer","and","numpy","generators",",","overwrites","model.__init__'s.","<","br",">","`","*","*","data_module_kwargs","`",":","PL","'s","TimeSeriesDataModule","args",",","see","[","documentation","]","(","https",":","\/\/pytorch-lightning.readthedocs.io\/en\/1.6.1\/extensions\/datamodules.html","#","using-a-datamodule",")","."]
code: def predict(
      self, dataset, step_size=1, random_seed=None, **data_module_kwargs
  ):
      """Predict.
  
      Neural network prediction with PL's `Trainer` execution of `predict_step`.
  
      **Parameters:**<br>
      `dataset`: NeuralForecast's `TimeSeriesDataset`, see [documentation](https://nixtla.github.io/neuralforecast/tsdataset.html).<br>
      `step_size`: int=1, Step size between each window.<br>
      `random_seed`: int=None, random_seed for pytorch initializer and numpy generators, overwrites model.__init__'s.<br>
      `**data_module_kwargs`: PL's TimeSeriesDataModule args, see [documentation](https://pytorch-lightning.readthedocs.io/en/1.6.1/extensions/datamodules.html#using-a-datamodule).
      """
  
      # Check exogenous variables are contained in dataset
      temporal_cols = set(dataset.temporal_cols.tolist())
      static_cols = set(
          dataset.static_cols.tolist()
          if dataset.static_cols is not None
          else []
      )
      if len(set(self.hist_exog_list) - temporal_cols) > 0:
          raise Exception(
              f"{set(self.hist_exog_list) - temporal_cols} historical exogenous variables not found in input dataset"
          )
      if len(set(self.futr_exog_list) - temporal_cols) > 0:
          raise Exception(
              f"{set(self.futr_exog_list) - temporal_cols} future exogenous variables not found in input dataset"
          )
      if len(set(self.stat_exog_list) - static_cols) > 0:
          raise Exception(
              f"{set(self.stat_exog_list) - static_cols} static exogenous variables not found in input dataset"
          )
  
      # Restart random seed
      if random_seed is None:
          random_seed = self.random_seed
      torch.manual_seed(random_seed)
  
      if step_size > 1:
          raise Exception(
              "Recurrent models do not support step_size > 1"
          )
  
      # fcsts (window, batch, h)
      # Protect when case of multiple gpu. PL does not support return preds with multiple gpu.
      pred_trainer_kwargs = self.trainer_kwargs.copy()
      if (pred_trainer_kwargs.get("accelerator", None) == "gpu") and (
          torch.cuda.device_count() > 1
      ):
          pred_trainer_kwargs["devices"] = [0]
  
      trainer = pl.Trainer(**pred_trainer_kwargs)
  
      datamodule = TimeSeriesDataModule(
          dataset=dataset,
          valid_batch_size=self.valid_batch_size,
          num_workers=self.num_workers_loader,
          **data_module_kwargs,
      )
      fcsts = trainer.predict(self, datamodule=datamodule)
      if self.test_size > 0:
          # Remove warmup windows (from train and validation)
          # [N,T,H,output], avoid indexing last dim for univariate output compatibility
          fcsts = torch.vstack(
              [
                  fcst[:, -(1 + self.test_size - self.h) :, :]
                  for fcst in fcsts
              ]
          )
          fcsts = fcsts.numpy().flatten()
          fcsts = fcsts.reshape(-1, len(self.loss.output_names))
      else:
          fcsts = (
              torch.vstack([fcst[:, -1:, :] for fcst in fcsts])
              .numpy()
              .flatten()
          )
          fcsts = fcsts.reshape(-1, len(self.loss.output_names))
      return fcsts
  
imports: import random
  import warnings
  import numpy
  import torch
  import torch.nn
  import pytorch_lightning
  from pytorch_lightning.callbacks import TQDMProgressBar
  from pytorch_lightning.callbacks.early_stopping import EarlyStopping
  from ._scalers import TemporalNorm
  from ..tsdataset import TimeSeriesDataModule
  from ..utils import get_indexer_raise_missing
label_desc: Use image node_id 15 for calling the BaseRecurrent obj's underlying member method code with example usage: obj.predict(dataset, step_size, random_seed) and returns: fcsts