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
      """
      # covariates
      if self.encoder_covariate_size > 0:
          encoder_features = self.extract_features(
              x, self.embeddings, period="encoder"
          )
          encoder_x_t = torch.concat(
              [
                  encoder_features[name]
                  for name in self.encoder_variables
                  if name not in self.target_names
              ],
              dim=2,
          )
      else:
          encoder_x_t = None
  
      if self.decoder_covariate_size > 0:
          decoder_features = self.extract_features(
              x, self.embeddings, period="decoder"
          )
          decoder_x_t = torch.concat(
              [
                  decoder_features[name]
                  for name in self.decoder_variables
              ],
              dim=2,
          )
      else:
          decoder_x_t = None
  
      # statics
      if self.static_size > 0:
          x_s = torch.concat(
              [
                  encoder_features[name][:, 0]
                  for name in self.static_variables
              ],
              dim=1,
          )
      else:
          x_s = None
  
      # target
      encoder_y = x["encoder_cont"][..., self.target_positions]
      encoder_mask = create_mask(
          x["encoder_lengths"].max(), x["encoder_lengths"], inverse=True
      )
  
      # run model
      forecast, backcast, block_forecasts, block_backcasts = self.model(
          encoder_y, encoder_mask, encoder_x_t, decoder_x_t, x_s
      )
      backcast = encoder_y - backcast
  
      # create block output: detach and split by block
      block_backcasts = block_backcasts.detach()
      block_forecasts = block_forecasts.detach()
  
      if isinstance(self.hparams.output_size, (tuple, list)):
          forecast = forecast.split(self.hparams.output_size, dim=2)
          backcast = backcast.split(1, dim=2)
          block_backcasts = tuple(
              self.transform_output(
                  block.squeeze(3).split(1, dim=2),
                  target_scale=x["target_scale"],
              )
              for block in block_backcasts.split(1, dim=3)
          )
          block_forecasts = tuple(
              self.transform_output(
                  block.squeeze(3).split(
                      self.hparams.output_size, dim=2
                  ),
                  target_scale=x["target_scale"],
              )
              for block in block_forecasts.split(1, dim=3)
          )
      else:
          block_backcasts = tuple(
              self.transform_output(
                  block.squeeze(3),
                  target_scale=x["target_scale"],
                  loss=MultiHorizonMetric(),
              )
              for block in block_backcasts.split(1, dim=3)
          )
          block_forecasts = tuple(
              self.transform_output(
                  block.squeeze(3), target_scale=x["target_scale"]
              )
              for block in block_forecasts.split(1, dim=3)
          )
  
      return self.to_network_output(
          prediction=self.transform_output(
              forecast, target_scale=x["target_scale"]
          ),  # (n_outputs x) n_samples x n_timesteps x output_size
          backcast=self.transform_output(
              backcast,
              target_scale=x["target_scale"],
              loss=MultiHorizonMetric(),
          ),  # (n_outputs x) n_samples x n_timesteps x 1
          block_backcasts=block_backcasts,  # n_blocks x (n_outputs x) n_samples x n_timesteps x 1
          block_forecasts=block_forecasts,  # n_blocks x (n_outputs x) n_samples x n_timesteps x output_size
      )
  
imports: from copy import copy
  from typing import Dict, List, Optional, Tuple, Union
  from matplotlib import pyplot
  import numpy
  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, MultiLoss
  from pytorch_forecasting.models.base_model import BaseModelWithCovariates
  from pytorch_forecasting.models.nhits.sub_modules import NHiTS
  from pytorch_forecasting.models.nn.embeddings import MultiEmbedding
  from pytorch_forecasting.utils import create_mask, detach, to_list
label_desc: Use image node_id 6 for calling the NHiTS obj's underlying member method code with example usage: obj.forward(x) and returns: self