docstr: PyTorch module implementing a residual block module used in `_TCNModule`.
  
  Parameters
  ----------
  num_filters
      The number of filters in a convolutional layer of the TCN.
  kernel_size
      The size of every kernel in a convolutional layer.
  dilation_base
      The base of the exponent that will determine the dilation on every level.
  dropout_fn
      The dropout function to be applied to every convolutional layer.
  weight_norm
      Boolean value indicating whether to use weight normalization.
  nr_blocks_below
      The number of residual blocks before the current one.
  num_layers
      The number of convolutional layers.
  input_size
      The dimensionality of the input time series of the whole network.
  target_size
      The dimensionality of the output time series of the whole network.
  
  Inputs
  ------
  x of shape `(batch_size, in_dimension, input_chunk_length)`
      Tensor containing the features of the input sequence.
      in_dimension is equal to `input_size` if this is the first residual block,
      in all other cases it is equal to `num_filters`.
  
  Outputs
  -------
  y of shape `(batch_size, out_dimension, input_chunk_length)`
      Tensor containing the output sequence of the residual block.
      out_dimension is equal to `output_size` if this is the last residual block,
      in all other cases it is equal to `num_filters`.
docstr_tok: ["PyTorch","module","implementing","a","residual","block","module","used","in","`","_TCNModule","`",".","Parameters","--","--","--","--","--","num_filters","The","number","of","filters","in","a","convolutional","layer","of","the","TCN",".","kernel_size","The","size","of","every","kernel","in","a","convolutional","layer",".","dilation_base","The","base","of","the","exponent","that","will","determine","the","dilation","on","every","level",".","dropout_fn","The","dropout","function","to","be","applied","to","every","convolutional","layer",".","weight_norm","Boolean","value","indicating","whether","to","use","weight","normalization",".","nr_blocks_below","The","number","of","residual","blocks","before","the","current","one",".","num_layers","The","number","of","convolutional","layers",".","input_size","The","dimensionality","of","the","input","time","series","of","the","whole","network",".","target_size","The","dimensionality","of","the","output","time","series","of","the","whole","network",".","Inputs","--","--","--","x","of","shape","`","(","batch_size",",","in_dimension",",","input_chunk_length",")","`","Tensor","containing","the","features","of","the","input","sequence",".","in_dimension","is","equal","to","`","input_size","`","if","this","is","the","first","residual","block",",","in","all","other","cases","it","is","equal","to","`","num_filters","`",".","Outputs","--","--","--","-","y","of","shape","`","(","batch_size",",","out_dimension",",","input_chunk_length",")","`","Tensor","containing","the","output","sequence","of","the","residual","block",".","out_dimension","is","equal","to","`","output_size","`","if","this","is","the","last","residual","block",",","in","all","other","cases","it","is","equal","to","`","num_filters","`","."]
code: def __init__(
      self,
      num_filters: int,
      kernel_size: int,
      dilation_base: int,
      dropout_fn,
      weight_norm: bool,
      nr_blocks_below: int,
      num_layers: int,
      input_size: int,
      target_size: int,
  ):
      """PyTorch module implementing a residual block module used in `_TCNModule`.
  
      Parameters
      ----------
      num_filters
          The number of filters in a convolutional layer of the TCN.
      kernel_size
          The size of every kernel in a convolutional layer.
      dilation_base
          The base of the exponent that will determine the dilation on every level.
      dropout_fn
          The dropout function to be applied to every convolutional layer.
      weight_norm
          Boolean value indicating whether to use weight normalization.
      nr_blocks_below
          The number of residual blocks before the current one.
      num_layers
          The number of convolutional layers.
      input_size
          The dimensionality of the input time series of the whole network.
      target_size
          The dimensionality of the output time series of the whole network.
  
      Inputs
      ------
      x of shape `(batch_size, in_dimension, input_chunk_length)`
          Tensor containing the features of the input sequence.
          in_dimension is equal to `input_size` if this is the first residual block,
          in all other cases it is equal to `num_filters`.
  
      Outputs
      -------
      y of shape `(batch_size, out_dimension, input_chunk_length)`
          Tensor containing the output sequence of the residual block.
          out_dimension is equal to `output_size` if this is the last residual block,
          in all other cases it is equal to `num_filters`.
      """
      super().__init__()
  
      self.dilation_base = dilation_base
      self.kernel_size = kernel_size
      self.dropout_fn = dropout_fn
      self.num_layers = num_layers
      self.nr_blocks_below = nr_blocks_below
  
      input_dim = input_size if nr_blocks_below == 0 else num_filters
      output_dim = (
          target_size
          if nr_blocks_below == num_layers - 1
          else num_filters
      )
      self.conv1 = nn.Conv1d(
          input_dim,
          num_filters,
          kernel_size,
          dilation=(dilation_base**nr_blocks_below),
      )
      self.conv2 = nn.Conv1d(
          num_filters,
          output_dim,
          kernel_size,
          dilation=(dilation_base**nr_blocks_below),
      )
      if weight_norm:
          self.conv1, self.conv2 = nn.utils.weight_norm(
              self.conv1
          ), nn.utils.weight_norm(self.conv2)
  
      if input_dim != output_dim:
          self.conv3 = nn.Conv1d(input_dim, output_dim, 1)
  
imports: import math
  from typing import Optional, Sequence, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from darts.logging import get_logger, raise_if_not
  from darts.models.forecasting.pl_forecasting_module import PLPastCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import PastCovariatesTorchModel
  from darts.timeseries import TimeSeries
  from darts.utils.data import PastCovariatesShiftedDataset
  from darts.utils.torch import MonteCarloDropout
label_desc: Use image node_id 1 to create a new _ResidualBlock object from inherited base classes: nn with example: obj = _ResidualBlock(num_filters, kernel_size, dilation_base, dropout_fn, weight_norm, nr_blocks_below, num_layers, input_size, target_size)