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: Fit.
  
  The `fit` method, optimizes the neural network's weights using the
  initialization parameters (`learning_rate`, `batch_size`, ...)
  and the `loss` function as defined during the initialization.
  Within `fit` we use a PyTorch Lightning `Trainer` that
  inherits the initialization's `self.trainer_kwargs`, to customize
  its inputs, see [PL's trainer arguments](https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.trainer.trainer.Trainer.html?highlight=trainer).
  
  The method is designed to be compatible with SKLearn-like classes
  and in particular to be compatible with the StatsForecast library.
  
  By default the `model` is not saving training checkpoints to protect
  disk memory, to get them change `enable_checkpointing=True` in `__init__`.
  
  **Parameters:**<br>
  `dataset`: NeuralForecast's `TimeSeriesDataset`, see [documentation](https://nixtla.github.io/neuralforecast/tsdataset.html).<br>
  `val_size`: int, validation size for temporal cross-validation.<br>
  `test_size`: int, test size for temporal cross-validation.<br>
  `random_seed`: int=None, random_seed for pytorch initializer and numpy generators, overwrites model.__init__'s.<br>
docstr_tok: ["Fit",".","The","`","fit","`","method",",","optimizes","the","neural","network","'s","weights","using","the","initialization","parameters","(","`","learning_rate","`",",","`","batch_size","`",",","...",")","and","the","`","loss","`","function","as","defined","during","the","initialization",".","Within","`","fit","`","we","use","a","PyTorch","Lightning","`","Trainer","`","that","inherits","the","initialization","'s","`","self.trainer_kwargs","`",",","to","customize","its","inputs",",","see","[","PL","'s","trainer","arguments","]","(","https",":","\/\/pytorch-lightning.readthedocs.io\/en\/stable\/api\/pytorch_lightning.trainer.trainer.Trainer.html","?","highlight=trainer",")",".","The","method","is","designed","to","be","compatible","with","SKLearn-like","classes","and","in","particular","to","be","compatible","with","the","StatsForecast","library",".","By","default","the","`","model","`","is","not","saving","training","checkpoints","to","protect","disk","memory",",","to","get","them","change","`","enable_checkpointing=True","`","in","`","__init__","`",".","*","*","Parameters",":","*","*","<","br",">","`","dataset","`",":","NeuralForecast","'s","`","TimeSeriesDataset","`",",","see","[","documentation","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/tsdataset.html",")",".","<","br",">","`","val_size","`",":","int",",","validation","size","for","temporal","cross-validation.","<","br",">","`","test_size","`",":","int",",","test","size","for","temporal","cross-validation.","<","br",">","`","random_seed","`",":","int=None",",","random_seed","for","pytorch","initializer","and","numpy","generators",",","overwrites","model.__init__'s.","<","br",">"]
code: def fit(self, dataset, val_size=0, test_size=0, random_seed=None):
      """Fit.
  
      The `fit` method, optimizes the neural network's weights using the
      initialization parameters (`learning_rate`, `batch_size`, ...)
      and the `loss` function as defined during the initialization.
      Within `fit` we use a PyTorch Lightning `Trainer` that
      inherits the initialization's `self.trainer_kwargs`, to customize
      its inputs, see [PL's trainer arguments](https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.trainer.trainer.Trainer.html?highlight=trainer).
  
      The method is designed to be compatible with SKLearn-like classes
      and in particular to be compatible with the StatsForecast library.
  
      By default the `model` is not saving training checkpoints to protect
      disk memory, to get them change `enable_checkpointing=True` in `__init__`.
  
      **Parameters:**<br>
      `dataset`: NeuralForecast's `TimeSeriesDataset`, see [documentation](https://nixtla.github.io/neuralforecast/tsdataset.html).<br>
      `val_size`: int, validation size for temporal cross-validation.<br>
      `test_size`: int, test size for temporal cross-validation.<br>
      `random_seed`: int=None, random_seed for pytorch initializer and numpy generators, overwrites model.__init__'s.<br>
      """
  
      # 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)
  
      self.val_size = val_size
      self.test_size = test_size
      datamodule = TimeSeriesDataModule(
          dataset=dataset,
          batch_size=self.batch_size,
          valid_batch_size=self.valid_batch_size,
          num_workers=self.num_workers_loader,
          drop_last=self.drop_last_loader,
      )
  
      if self.val_check_steps > self.max_steps:
          warnings.warn(
              "val_check_steps is greater than max_steps, \
                      setting val_check_steps to max_steps"
          )
      val_check_interval = min(self.val_check_steps, self.max_steps)
      self.trainer_kwargs["val_check_interval"] = int(
          val_check_interval
      )
      self.trainer_kwargs["check_val_every_n_epoch"] = None
  
      trainer = pl.Trainer(**self.trainer_kwargs)
      trainer.fit(self, datamodule=datamodule)
  
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 14 for calling the BaseRecurrent obj's underlying member method code with example usage: obj.fit(dataset, val_size, test_size, random_seed) without return types