docstr: Pass forward of network.
  
  Args:
      x (Dict[str, torch.Tensor]): input from dataloader generated from
          :py:class:`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`.
  
  Returns:
      Dict[str, torch.Tensor]: output of model
docstr_tok: ["Pass","forward","of","network",".","Args",":","x","(","Dict","[","str",",","torch.Tensor","]",")",":","input","from","dataloader","generated","from",":","py",":","class",":","`","~pytorch_forecasting.data.timeseries.TimeSeriesDataSet","`",".","Returns",":","Dict","[","str",",","torch.Tensor","]",":","output","of","model"]
code: def forward(
      self, x: Dict[str, torch.Tensor]
  ) -> Dict[str, torch.Tensor]:
      """
      Pass forward of network.
  
      Args:
          x (Dict[str, torch.Tensor]): input from dataloader generated from
              :py:class:`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`.
  
      Returns:
          Dict[str, torch.Tensor]: output of model
      """
      target = x["encoder_cont"][..., 0]
  
      timesteps = (
          self.hparams.context_length + self.hparams.prediction_length
      )
      generic_forecast = [
          torch.zeros(
              (target.size(0), timesteps),
              dtype=torch.float32,
              device=self.device,
          )
      ]
      trend_forecast = [
          torch.zeros(
              (target.size(0), timesteps),
              dtype=torch.float32,
              device=self.device,
          )
      ]
      seasonal_forecast = [
          torch.zeros(
              (target.size(0), timesteps),
              dtype=torch.float32,
              device=self.device,
          )
      ]
      forecast = torch.zeros(
          (target.size(0), self.hparams.prediction_length),
          dtype=torch.float32,
          device=self.device,
      )
  
      backcast = target  # initialize backcast
      for i, block in enumerate(self.net_blocks):
          # evaluate block
          backcast_block, forecast_block = block(backcast)
  
          # add for interpretation
          full = torch.cat(
              [backcast_block.detach(), forecast_block.detach()], dim=1
          )
          if isinstance(block, NBEATSTrendBlock):
              trend_forecast.append(full)
          elif isinstance(block, NBEATSSeasonalBlock):
              seasonal_forecast.append(full)
          else:
              generic_forecast.append(full)
  
          # update backcast and forecast
          backcast = (
              backcast - backcast_block
          )  # do not use backcast -= backcast_block as this signifies an inline operation
          forecast = forecast + forecast_block
  
      return self.to_network_output(
          prediction=self.transform_output(
              forecast, target_scale=x["target_scale"]
          ),
          backcast=self.transform_output(
              prediction=target - backcast,
              target_scale=x["target_scale"],
          ),
          trend=self.transform_output(
              torch.stack(trend_forecast, dim=0).sum(0),
              target_scale=x["target_scale"],
          ),
          seasonality=self.transform_output(
              torch.stack(seasonal_forecast, dim=0).sum(0),
              target_scale=x["target_scale"],
          ),
          generic=self.transform_output(
              torch.stack(generic_forecast, dim=0).sum(0),
              target_scale=x["target_scale"],
          ),
      )
  
file_path: pytorch-forecasting/pytorch_forecasting/models/nbeats/__init__.py
imports: from typing import Dict, List
  import matplotlib.pyplot
  import torch
  from torch import nn
  from pytorch_forecasting.data import TimeSeriesDataSet
  from pytorch_forecasting.data.encoders import NaNLabelEncoder
  from pytorch_forecasting.metrics import MAE, MAPE, MASE, RMSE, SMAPE, MultiHorizonMetric
  from pytorch_forecasting.models.base_model import BaseModel
  from pytorch_forecasting.models.nbeats.sub_modules import NBEATSGenericBlock, NBEATSSeasonalBlock, NBEATSTrendBlock
label_desc: Use image node_id 2 for calling the NBeats obj's underlying member method code with example usage: obj.forward(x) and returns: self