docstr: This class allows to create custom RNN modules that can later be used with Darts' :class:`RNNModel`.
  It adds the backbone that is required to be used with Darts' :class:`TorchForecastingModel` and
  :class:`RNNModel`.
  
  To create a new module, subclass from :class:`CustomRNNModule` and:
  
  * Define the architecture in the module constructor (`__init__()`)
  
  * Add the `forward()` method and define the logic of your module's forward pass
  
  * Use the custom module class when creating a new :class:`RNNModel` with parameter `model`.
  
  You can use `darts.models.forecasting.rnn_model._RNNModule` as an example.
  
  Parameters
  ----------
  input_size
      The dimensionality of the input time series.
  hidden_dim
      The number of features in the hidden state `h` of the RNN module.
  num_layers
      The number of recurrent layers.
  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).
  dropout
      The fraction of neurons that are dropped in all-but-last RNN layers.
  **kwargs
      all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
docstr_tok: ["This","class","allows","to","create","custom","RNN","modules","that","can","later","be","used","with","Darts","'",":","class",":","`","RNNModel","`",".","It","adds","the","backbone","that","is","required","to","be","used","with","Darts","'",":","class",":","`","TorchForecastingModel","`","and",":","class",":","`","RNNModel","`",".","To","create","a","new","module",",","subclass","from",":","class",":","`","CustomRNNModule","`","and",":","*","Define","the","architecture","in","the","module","constructor","(","`","__init__","(",")","`",")","*","Add","the","`","forward","(",")","`","method","and","define","the","logic","of","your","module","'s","forward","pass","*","Use","the","custom","module","class","when","creating","a","new",":","class",":","`","RNNModel","`","with","parameter","`","model","`",".","You","can","use","`","darts.models.forecasting.rnn_model._RNNModule","`","as","an","example",".","Parameters","--","--","--","--","--","input_size","The","dimensionality","of","the","input","time","series",".","hidden_dim","The","number","of","features","in","the","hidden","state","`","h","`","of","the","RNN","module",".","num_layers","The","number","of","recurrent","layers",".","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",")",".","dropout","The","fraction","of","neurons","that","are","dropped","in","all-but-last","RNN","layers",".","*","*","kwargs","all","parameters","required","for",":","class",":","`","darts.model.forecasting_models.PLForecastingModule","`","base","class","."]
code: def __init__(
      self,
      input_size: int,
      hidden_dim: int,
      num_layers: int,
      target_size: int,
      nr_params: int,
      dropout: float = 0.0,
      **kwargs,
  ):
      """This class allows to create custom RNN modules that can later be used with Darts' :class:`RNNModel`.
      It adds the backbone that is required to be used with Darts' :class:`TorchForecastingModel` and
      :class:`RNNModel`.
  
      To create a new module, subclass from :class:`CustomRNNModule` and:
  
      * Define the architecture in the module constructor (`__init__()`)
  
      * Add the `forward()` method and define the logic of your module's forward pass
  
      * Use the custom module class when creating a new :class:`RNNModel` with parameter `model`.
  
      You can use `darts.models.forecasting.rnn_model._RNNModule` as an example.
  
      Parameters
      ----------
      input_size
          The dimensionality of the input time series.
      hidden_dim
          The number of features in the hidden state `h` of the RNN module.
      num_layers
          The number of recurrent layers.
      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).
      dropout
          The fraction of neurons that are dropped in all-but-last RNN layers.
      **kwargs
          all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
      """
      # RNNModule doesn't really need input and output_chunk_length for PLModule
      super().__init__(**kwargs)
  
      # Defining parameters
      self.input_size = input_size
      self.hidden_dim = hidden_dim
      self.num_layers = num_layers
      self.target_size = target_size
      self.nr_params = nr_params
      self.dropout = dropout
  
imports: import inspect
  from abc import ABC, abstractmethod
  from typing import Optional, Sequence, Tuple, Type, Union
  import torch
  import torch.nn
  from darts.logging import get_logger, raise_if_not, raise_log
  from darts.models.forecasting.pl_forecasting_module import PLDualCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import DualCovariatesTorchModel
  from darts.timeseries import TimeSeries
  from darts.utils.data import DualCovariatesShiftedDataset, TrainingDataset
label_desc: Use image node_id 1 to create a new CustomRNNModule object from inherited base classes: PLDualCovariatesModule, ABC with example: obj = CustomRNNModule(input_size, hidden_dim, num_layers, target_size, nr_params, dropout)