class_docstr: NBEATSx
  
  The Neural Basis Expansion Analysis with Exogenous variables (NBEATSx) is a simple
  and effective deep learning architecture. It is built with a deep stack of MLPs with
  doubly residual connections. The NBEATSx architecture includes additional exogenous
  blocks, extending NBEATS capabilities and interpretability. With its interpretable
  version, NBEATSx decomposes its predictions on seasonality, trend, and exogenous effects.
  
  **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>
  `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>
  `exclude_insample_y`: bool=False, the model skips the autoregressive features y[t-input_size:t] if True.<br>
  `n_harmonics`: int, Number of harmonic oscillations in the SeasonalityBasis [cos(i * t/n_harmonics), sin(i * t/n_harmonics)]. Note that it will only be used if 'seasonality' is in `stack_types`.<br>
  `n_polynomials`: int, Number of polynomial terms for TrendBasis [1,t,...,t^n_poly]. Note that it will only be used if 'trend' is in `stack_types`.<br>
  `stack_types`: List[str], List of stack types. Subset from ['seasonality', 'trend', 'identity'].<br>
  `n_blocks`: List[int], Number of blocks for each stack. Note that len(n_blocks) = len(stack_types).<br>
  `mlp_units`: List[List[int]], Structure of hidden layers for each stack type. Each internal list should contain the number of units of each hidden layer. Note that len(n_hidden) = len(stack_types).<br>
  `dropout_prob_theta`: float, Float between (0, 1). Dropout for N-BEATS basis.<br>
  `activation`: str, activation from ['ReLU', 'Softplus', 'Tanh', 'SELU', 'LeakyReLU', 'PReLU', 'Sigmoid'].<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=3, 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=32, number of different series in each batch.<br>
  `valid_batch_size`: int=None, number of different series in each validation and test batch, if None uses batch_size.<br>
  `windows_batch_size`: int=1024, number of windows to sample in each training batch, default uses all.<br>
  `inference_windows_batch_size`: int=-1, number of windows to sample in each inference batch, -1 uses all.<br>
  `start_padding_enabled`: bool=False, if True, the model will pad the time series with zeros at the beginning, by input size.<br>
  `step_size`: int=1, step size between each window of temporal data.<br>
  `scaler_type`: str='identity', type of scaler for temporal inputs normalization see [temporal scalers](https://nixtla.github.io/neuralforecast/common.scalers.html).<br>
  `random_seed`: int, random seed initialization for replicability.<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>
  
  **References:**<br>
  -[Kin G. Olivares, Cristian Challu, Grzegorz Marcjasz, Rafał Weron, Artur Dubrawski (2021).
  "Neural basis expansion analysis with exogenous variables: Forecasting electricity prices with NBEATSx".](https://arxiv.org/abs/2104.05522)
class_docstr_tok: ["NBEATSx","The","Neural","Basis","Expansion","Analysis","with","Exogenous","variables","(","NBEATSx",")","is","a","simple","and","effective","deep","learning","architecture",".","It","is","built","with","a","deep","stack","of","MLPs","with","doubly","residual","connections",".","The","NBEATSx","architecture","includes","additional","exogenous","blocks",",","extending","NBEATS","capabilities","and","interpretability",".","With","its","interpretable","version",",","NBEATSx","decomposes","its","predictions","on","seasonality",",","trend",",","and","exogenous","effects",".","*","*","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",">","`","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",">","`","exclude_insample_y","`",":","bool=False",",","the","model","skips","the","autoregressive","features","y","[","t-input_size",":","t","]","if","True.","<","br",">","`","n_harmonics","`",":","int",",","Number","of","harmonic","oscillations","in","the","SeasonalityBasis","[","cos","(","i","*","t\/n_harmonics",")",",","sin","(","i","*","t\/n_harmonics",")","]",".","Note","that","it","will","only","be","used","if","'seasonality","'","is","in","`","stack_types","`",".","<","br",">","`","n_polynomials","`",":","int",",","Number","of","polynomial","terms","for","TrendBasis","[","1",",","t",",","...",",","t^n_poly","]",".","Note","that","it","will","only","be","used","if","'trend","'","is","in","`","stack_types","`",".","<","br",">","`","stack_types","`",":","List","[","str","]",",","List","of","stack","types",".","Subset","from","[","'seasonality","'",",","'trend","'",",","'identity","'","]",".","<","br",">","`","n_blocks","`",":","List","[","int","]",",","Number","of","blocks","for","each","stack",".","Note","that","len","(","n_blocks",")","=","len","(","stack_types",")",".","<","br",">","`","mlp_units","`",":","List","[","List","[","int","]","]",",","Structure","of","hidden","layers","for","each","stack","type",".","Each","internal","list","should","contain","the","number","of","units","of","each","hidden","layer",".","Note","that","len","(","n_hidden",")","=","len","(","stack_types",")",".","<","br",">","`","dropout_prob_theta","`",":","float",",","Float","between","(","0",",","1",")",".","Dropout","for","N-BEATS","basis.","<","br",">","`","activation","`",":","str",",","activation","from","[","'ReLU","'",",","'Softplus","'",",","'Tanh","'",",","'SELU","'",",","'LeakyReLU","'",",","'PReLU","'",",","'Sigmoid","'","]",".","<","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=3",",","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=32",",","number","of","different","series","in","each","batch.","<","br",">","`","valid_batch_size","`",":","int=None",",","number","of","different","series","in","each","validation","and","test","batch",",","if","None","uses","batch_size.","<","br",">","`","windows_batch_size","`",":","int=1024",",","number","of","windows","to","sample","in","each","training","batch",",","default","uses","all.","<","br",">","`","inference_windows_batch_size","`",":","int=-1",",","number","of","windows","to","sample","in","each","inference","batch",",","-1","uses","all.","<","br",">","`","start_padding_enabled","`",":","bool=False",",","if","True",",","the","model","will","pad","the","time","series","with","zeros","at","the","beginning",",","by","input","size.","<","br",">","`","step_size","`",":","int=1",",","step","size","between","each","window","of","temporal","data.","<","br",">","`","scaler_type","`",":","str='identity","'",",","type","of","scaler","for","temporal","inputs","normalization","see","[","temporal","scalers","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/common.scalers.html",")",".","<","br",">","`","random_seed","`",":","int",",","random","seed","initialization","for","replicability.","<","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",">","*","*","References",":","*","*","<","br",">","-","[","Kin","G.","Olivares",",","Cristian","Challu",",","Grzegorz","Marcjasz",",","Rafa\u0142","Weron",",","Artur","Dubrawski","(","2021",")",".","``","Neural","basis","expansion","analysis","with","exogenous","variables",":","Forecasting","electricity","prices","with","NBEATSx","''",".","]","(","https",":","\/\/arxiv.org\/abs\/2104.05522",")"]
code: def forward(self, windows_batch):
      # Parse windows_batch
      insample_y = windows_batch["insample_y"]
      insample_mask = windows_batch["insample_mask"]
      futr_exog = windows_batch["futr_exog"]
      hist_exog = windows_batch["hist_exog"]
      stat_exog = windows_batch["stat_exog"]
  
      # NBEATSx' forward
      residuals = insample_y.flip(dims=(-1,))  # backcast init
      insample_mask = insample_mask.flip(dims=(-1,))
  
      forecast = insample_y[:, -1:, None]  # Level with Naive1
      block_forecasts = [forecast.repeat(1, self.h, 1)]
      for i, block in enumerate(self.blocks):
          backcast, block_forecast = block(
              insample_y=residuals,
              futr_exog=futr_exog,
              hist_exog=hist_exog,
              stat_exog=stat_exog,
          )
          residuals = (residuals - backcast) * insample_mask
          forecast = forecast + block_forecast
  
          if self.decompose_forecast:
              block_forecasts.append(block_forecast)
  
      # Adapting output's domain
      forecast = self.loss.domain_map(forecast)
  
      if self.decompose_forecast:
          # (n_batch, n_blocks, h)
          block_forecasts = torch.stack(block_forecasts)
          block_forecasts = block_forecasts.permute(1, 0, 2, 3)
          block_forecasts = block_forecasts.squeeze(
              -1
          )  # univariate output
          return block_forecasts
      else:
          return forecast
  
imports: from typing import Tuple, Optional
  import numpy
  import torch
  import torch.nn
  from ..losses.pytorch import MAE
  from ..common._base_windows import BaseWindows
label_desc: Use image node_id 3 for calling the NBEATSx obj's underlying member method code with example usage: obj.forward(windows_batch) and returns: block_forecasts, forecast