docstr: PyTorch module implementing one stack of the N-BEATS architecture that comprises multiple basic blocks.
  
  Parameters
  ----------
  num_blocks
      The number of blocks making up this stack.
  num_layers
      The number of fully connected layers preceding the final forking layers in each block.
  layer_width
      The number of neurons that make up each fully connected layer in each block.
  nr_params
      The number of parameters of the likelihood (or 1 if no likelihood is used)
  expansion_coefficient_dim
      The dimensionality of the waveform generator parameters, also known as expansion coefficients.
  input_chunk_length
      The length of the input sequence fed to the model.
  target_length
      The length of the forecast of the model.
  g_type
      The function that is implemented by the waveform generators in each block.
  batch_norm
      whether to apply batch norm on first block of this stack
  dropout
      Dropout probability
  activation
      The activation function of encoder/decoder intermediate layer.
  
  Inputs
  ------
  stack_input of shape `(batch_size, input_chunk_length)`
      Tensor containing the input sequence.
  
  Outputs
  -------
  stack_residual of shape `(batch_size, input_chunk_length)`
      Tensor containing the 'backcast' of the block, which represents an approximation of `x`
      given the constraints of the functional space determined by `g`.
  stack_forecast of shape `(batch_size, output_chunk_length)`
      Tensor containing the forward forecast of the stack.
docstr_tok: ["PyTorch","module","implementing","one","stack","of","the","N-BEATS","architecture","that","comprises","multiple","basic","blocks",".","Parameters","--","--","--","--","--","num_blocks","The","number","of","blocks","making","up","this","stack",".","num_layers","The","number","of","fully","connected","layers","preceding","the","final","forking","layers","in","each","block",".","layer_width","The","number","of","neurons","that","make","up","each","fully","connected","layer","in","each","block",".","nr_params","The","number","of","parameters","of","the","likelihood","(","or","1","if","no","likelihood","is","used",")","expansion_coefficient_dim","The","dimensionality","of","the","waveform","generator","parameters",",","also","known","as","expansion","coefficients",".","input_chunk_length","The","length","of","the","input","sequence","fed","to","the","model",".","target_length","The","length","of","the","forecast","of","the","model",".","g_type","The","function","that","is","implemented","by","the","waveform","generators","in","each","block",".","batch_norm","whether","to","apply","batch","norm","on","first","block","of","this","stack","dropout","Dropout","probability","activation","The","activation","function","of","encoder\/decoder","intermediate","layer",".","Inputs","--","--","--","stack_input","of","shape","`","(","batch_size",",","input_chunk_length",")","`","Tensor","containing","the","input","sequence",".","Outputs","--","--","--","-","stack_residual","of","shape","`","(","batch_size",",","input_chunk_length",")","`","Tensor","containing","the","'backcast","'","of","the","block",",","which","represents","an","approximation","of","`","x","`","given","the","constraints","of","the","functional","space","determined","by","`","g","`",".","stack_forecast","of","shape","`","(","batch_size",",","output_chunk_length",")","`","Tensor","containing","the","forward","forecast","of","the","stack","."]
code: def __init__(
      self,
      num_blocks: int,
      num_layers: int,
      layer_width: int,
      nr_params: int,
      expansion_coefficient_dim: int,
      input_chunk_length: int,
      target_length: int,
      g_type: GTypes,
      batch_norm: bool,
      dropout: float,
      activation: str,
  ):
      """PyTorch module implementing one stack of the N-BEATS architecture that comprises multiple basic blocks.
  
      Parameters
      ----------
      num_blocks
          The number of blocks making up this stack.
      num_layers
          The number of fully connected layers preceding the final forking layers in each block.
      layer_width
          The number of neurons that make up each fully connected layer in each block.
      nr_params
          The number of parameters of the likelihood (or 1 if no likelihood is used)
      expansion_coefficient_dim
          The dimensionality of the waveform generator parameters, also known as expansion coefficients.
      input_chunk_length
          The length of the input sequence fed to the model.
      target_length
          The length of the forecast of the model.
      g_type
          The function that is implemented by the waveform generators in each block.
      batch_norm
          whether to apply batch norm on first block of this stack
      dropout
          Dropout probability
      activation
          The activation function of encoder/decoder intermediate layer.
  
      Inputs
      ------
      stack_input of shape `(batch_size, input_chunk_length)`
          Tensor containing the input sequence.
  
      Outputs
      -------
      stack_residual of shape `(batch_size, input_chunk_length)`
          Tensor containing the 'backcast' of the block, which represents an approximation of `x`
          given the constraints of the functional space determined by `g`.
      stack_forecast of shape `(batch_size, output_chunk_length)`
          Tensor containing the forward forecast of the stack.
  
      """
      super().__init__()
  
      self.input_chunk_length = input_chunk_length
      self.target_length = target_length
      self.nr_params = nr_params
      self.dropout = dropout
      self.batch_norm = batch_norm
      self.activation = activation
  
      if g_type == _GType.GENERIC:
          self.blocks_list = [
              _Block(
                  num_layers,
                  layer_width,
                  nr_params,
                  expansion_coefficient_dim,
                  input_chunk_length,
                  target_length,
                  g_type,
                  batch_norm=(
                      self.batch_norm and i == 0
                  ),  # batch norm only on first block of first stack
                  dropout=self.dropout,
                  activation=self.activation,
              )
              for i in range(num_blocks)
          ]
      else:
          # same block instance is used for weight sharing
          interpretable_block = _Block(
              num_layers,
              layer_width,
              nr_params,
              expansion_coefficient_dim,
              input_chunk_length,
              target_length,
              g_type,
              batch_norm=self.batch_norm,
              dropout=self.dropout,
              activation=self.activation,
          )
          self.blocks_list = [interpretable_block] * num_blocks
  
      self.blocks = nn.ModuleList(self.blocks_list)
  
imports: from enum import Enum
  from typing import List, NewType, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.models.forecasting.pl_forecasting_module import PLPastCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import PastCovariatesTorchModel
  from darts.utils.torch import MonteCarloDropout
label_desc: Use image node_id 1 to create a new _Stack object from inherited base classes: nn with example: obj = _Stack(num_blocks, num_layers, layer_width, nr_params, expansion_coefficient_dim, input_chunk_length, target_length, g_type, batch_norm, dropout, activation)