docstr: PyTorch module implementing a dilated TCN module used in `TCNModel`.
  
  
  Parameters
  ----------
  input_size
      The dimensionality of the input time series.
  target_size
      The dimensionality of the output time series.
  nr_params
      The number of parameters of the likelihood (or 1 if no likelihood is used).
  target_length
      Number of time steps the torch module will predict into the future at once.
  kernel_size
      The size of every kernel in a convolutional layer.
  num_filters
      The number of filters in a convolutional layer of the TCN.
  num_layers
      The number of convolutional layers.
  weight_norm
      Boolean value indicating whether to use weight normalization.
  dilation_base
      The base of the exponent that will determine the dilation on every level.
  dropout
      The dropout rate for every convolutional layer.
  **kwargs
      all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
  
  Inputs
  ------
  x of shape `(batch_size, input_chunk_length, input_size)`
      Tensor containing the features of the input sequence.
  
  Outputs
  -------
  y of shape `(batch_size, input_chunk_length, target_size, nr_params)`
      Tensor containing the predictions of the next 'output_chunk_length' points in the last
      'output_chunk_length' entries of the tensor. The entries before contain the data points
      leading up to the first prediction, all in chronological order.
docstr_tok: ["PyTorch","module","implementing","a","dilated","TCN","module","used","in","`","TCNModel","`",".","Parameters","--","--","--","--","--","input_size","The","dimensionality","of","the","input","time","series",".","target_size","The","dimensionality","of","the","output","time","series",".","nr_params","The","number","of","parameters","of","the","likelihood","(","or","1","if","no","likelihood","is","used",")",".","target_length","Number","of","time","steps","the","torch","module","will","predict","into","the","future","at","once",".","kernel_size","The","size","of","every","kernel","in","a","convolutional","layer",".","num_filters","The","number","of","filters","in","a","convolutional","layer","of","the","TCN",".","num_layers","The","number","of","convolutional","layers",".","weight_norm","Boolean","value","indicating","whether","to","use","weight","normalization",".","dilation_base","The","base","of","the","exponent","that","will","determine","the","dilation","on","every","level",".","dropout","The","dropout","rate","for","every","convolutional","layer",".","*","*","kwargs","all","parameters","required","for",":","class",":","`","darts.model.forecasting_models.PLForecastingModule","`","base","class",".","Inputs","--","--","--","x","of","shape","`","(","batch_size",",","input_chunk_length",",","input_size",")","`","Tensor","containing","the","features","of","the","input","sequence",".","Outputs","--","--","--","-","y","of","shape","`","(","batch_size",",","input_chunk_length",",","target_size",",","nr_params",")","`","Tensor","containing","the","predictions","of","the","next","'output_chunk_length","'","points","in","the","last","'output_chunk_length","'","entries","of","the","tensor",".","The","entries","before","contain","the","data","points","leading","up","to","the","first","prediction",",","all","in","chronological","order","."]
code: def __init__(
      self,
      input_size: int,
      kernel_size: int,
      num_filters: int,
      num_layers: Optional[int],
      dilation_base: int,
      weight_norm: bool,
      target_size: int,
      nr_params: int,
      target_length: int,
      dropout: float,
      **kwargs,
  ):
      """PyTorch module implementing a dilated TCN module used in `TCNModel`.
  
  
      Parameters
      ----------
      input_size
          The dimensionality of the input time series.
      target_size
          The dimensionality of the output time series.
      nr_params
          The number of parameters of the likelihood (or 1 if no likelihood is used).
      target_length
          Number of time steps the torch module will predict into the future at once.
      kernel_size
          The size of every kernel in a convolutional layer.
      num_filters
          The number of filters in a convolutional layer of the TCN.
      num_layers
          The number of convolutional layers.
      weight_norm
          Boolean value indicating whether to use weight normalization.
      dilation_base
          The base of the exponent that will determine the dilation on every level.
      dropout
          The dropout rate for every convolutional layer.
      **kwargs
          all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
  
      Inputs
      ------
      x of shape `(batch_size, input_chunk_length, input_size)`
          Tensor containing the features of the input sequence.
  
      Outputs
      -------
      y of shape `(batch_size, input_chunk_length, target_size, nr_params)`
          Tensor containing the predictions of the next 'output_chunk_length' points in the last
          'output_chunk_length' entries of the tensor. The entries before contain the data points
          leading up to the first prediction, all in chronological order.
      """
  
      super().__init__(**kwargs)
  
      # Defining parameters
      self.input_size = input_size
      self.n_filters = num_filters
      self.kernel_size = kernel_size
      self.target_length = target_length
      self.target_size = target_size
      self.nr_params = nr_params
      self.dilation_base = dilation_base
      self.dropout = MonteCarloDropout(p=dropout)
  
      # If num_layers is not passed, compute number of layers needed for full history coverage
      if num_layers is None and dilation_base > 1:
          num_layers = math.ceil(
              math.log(
                  (self.input_chunk_length - 1)
                  * (dilation_base - 1)
                  / (kernel_size - 1)
                  / 2
                  + 1,
                  dilation_base,
              )
          )
          logger.info("Number of layers chosen: " + str(num_layers))
      elif num_layers is None:
          num_layers = math.ceil(
              (self.input_chunk_length - 1) / (kernel_size - 1) / 2
          )
          logger.info("Number of layers chosen: " + str(num_layers))
      self.num_layers = num_layers
  
      # Building TCN module
      self.res_blocks_list = []
      for i in range(num_layers):
          res_block = _ResidualBlock(
              num_filters,
              kernel_size,
              dilation_base,
              self.dropout,
              weight_norm,
              i,
              num_layers,
              self.input_size,
              target_size * nr_params,
          )
          self.res_blocks_list.append(res_block)
      self.res_blocks = nn.ModuleList(self.res_blocks_list)
  
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 _TCNModule object from inherited base classes: PLPastCovariatesModule with example: obj = _TCNModule(input_size, kernel_size, num_filters, num_layers, dilation_base, weight_norm, target_size, nr_params, target_length, dropout)