class_docstr: StemGNN
  
  The Spectral Temporal Graph Neural Network (`StemGNN`) is a Graph-based multivariate
  time-series forecasting model. `StemGNN` jointly learns temporal dependencies and
  inter-series correlations in the spectral domain, by combining Graph Fourier Transform (GFT)
  and Discrete Fourier Transform (DFT).
  
  **Parameters:**<br>
  `h`: int, Forecast horizon. <br>
  `input_size`: int, autorregresive inputs size, y=[1,2,3,4] input_size=2 -> y_[t-2:t]=[1,2].<br>
  `n_series`: int, number of time-series.<br>
  `stat_exog_list`: str list, static exogenous columns.<br>
  `hist_exog_list`: str list, historic exogenous columns.<br>
  `futr_exog_list`: str list, future exogenous columns.<br>
  `n_stacks`: int=2, number of stacks in the model.<br>
  `multi_layer`: int=5, multiplier for FC hidden size on StemGNN blocks.<br>
  `dropout_rate`: float=0.5, dropout rate.<br>
  `leaky_rate`: float=0.2, alpha for LeakyReLU layer on Latent Correlation layer.<br>
  `loss`: PyTorch module, instantiated train loss class from [losses collection](https://nixtla.github.io/neuralforecast/losses.pytorch.html).<br>
  `valid_loss`: PyTorch module=`loss`, instantiated valid loss class from [losses collection](https://nixtla.github.io/neuralforecast/losses.pytorch.html).<br>
  `max_steps`: int=1000, maximum number of training steps.<br>
  `learning_rate`: float=1e-3, Learning rate between (0, 1).<br>
  `num_lr_decays`: int=-1, Number of learning rate decays, evenly distributed across max_steps.<br>
  `early_stop_patience_steps`: int=-1, Number of validation iterations before early stopping.<br>
  `val_check_steps`: int=100, Number of training steps between every validation loss check.<br>
  `batch_size`: int, number of windows in each batch.<br>
  `step_size`: int=1, step size between each window of temporal data.<br>
  `scaler_type`: str='robust', type of scaler for temporal inputs normalization see [temporal scalers](https://nixtla.github.io/neuralforecast/common.scalers.html).<br>
  `random_seed`: int, random_seed for pytorch initializer and numpy generators.<br>
  `num_workers_loader`: int=os.cpu_count(), workers to be used by `TimeSeriesDataLoader`.<br>
  `drop_last_loader`: bool=False, if True `TimeSeriesDataLoader` drops last non-full batch.<br>
  `alias`: str, optional,  Custom name of the model.<br>
  `**trainer_kwargs`: int,  keyword trainer arguments inherited from [PyTorch Lighning's trainer](https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.trainer.trainer.Trainer.html?highlight=trainer).<br>
code: def __init__(
      self,
      h,
      input_size,
      n_series,
      futr_exog_list=None,
      hist_exog_list=None,
      stat_exog_list=None,
      n_stacks=2,
      multi_layer: int = 5,
      dropout_rate: float = 0.5,
      leaky_rate: float = 0.2,
      loss=MAE(),
      valid_loss=None,
      max_steps: int = 1000,
      learning_rate: float = 1e-3,
      num_lr_decays: int = 3,
      early_stop_patience_steps: int = -1,
      val_check_steps: int = 100,
      batch_size: int = 32,
      step_size: int = 1,
      scaler_type: str = "robust",
      random_seed: int = 1,
      num_workers_loader=0,
      drop_last_loader=False,
      **trainer_kwargs,
  ):
      # Inherit BaseMultivariate class
      super(StemGNN, self).__init__(
          h=h,
          input_size=input_size,
          n_series=n_series,
          futr_exog_list=futr_exog_list,
          hist_exog_list=hist_exog_list,
          stat_exog_list=stat_exog_list,
          loss=loss,
          valid_loss=valid_loss,
          max_steps=max_steps,
          learning_rate=learning_rate,
          num_lr_decays=num_lr_decays,
          early_stop_patience_steps=early_stop_patience_steps,
          val_check_steps=val_check_steps,
          batch_size=batch_size,
          step_size=step_size,
          scaler_type=scaler_type,
          num_workers_loader=num_workers_loader,
          drop_last_loader=drop_last_loader,
          random_seed=random_seed,
          **trainer_kwargs,
      )
  
      # Exogenous variables
      self.futr_input_size = len(self.futr_exog_list)
      self.hist_input_size = len(self.hist_exog_list)
      self.stat_input_size = len(self.stat_exog_list)
  
      self.unit = n_series
      self.stack_cnt = n_stacks
      self.alpha = leaky_rate
      self.time_step = input_size
      self.horizon = h
      self.h = h
  
      self.weight_key = nn.Parameter(torch.zeros(size=(self.unit, 1)))
      nn.init.xavier_uniform_(self.weight_key.data, gain=1.414)
      self.weight_query = nn.Parameter(torch.zeros(size=(self.unit, 1)))
      nn.init.xavier_uniform_(self.weight_query.data, gain=1.414)
      self.GRU = nn.GRU(self.time_step, self.unit)
      self.multi_layer = multi_layer
      self.stock_block = nn.ModuleList()
      self.stock_block.extend(
          [
              StockBlockLayer(
                  self.time_step,
                  self.unit,
                  self.multi_layer,
                  stack_cnt=i,
              )
              for i in range(self.stack_cnt)
          ]
      )
      self.fc = nn.Sequential(
          nn.Linear(int(self.time_step), int(self.time_step)),
          nn.LeakyReLU(),
          nn.Linear(int(self.time_step), self.horizon),
      )
      self.leakyrelu = nn.LeakyReLU(self.alpha)
      self.dropout = nn.Dropout(p=dropout_rate)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ..losses.pytorch import MAE
  from ..common._base_multivariate import BaseMultivariate
label_desc: Use image node_id 1 to create a new StemGNN object from inherited base classes: BaseMultivariate with example: obj = StemGNN(h, input_size, n_series, futr_exog_list, hist_exog_list, stat_exog_list, n_stacks, multi_layer, dropout_rate, leaky_rate, loss, valid_loss, max_steps, learning_rate, num_lr_decays, early_stop_patience_steps, val_check_steps, batch_size, step_size, scaler_type, random_seed, num_workers_loader, drop_last_loader)