class_docstr: Base class for all RNN-like sequence models.
  
  DP-friendly drop-in replacement of the ``torch.nn.RNNBase`` module.
  After training this module can be exported and loaded by the original ``torch.nn``
  implementation for inference.
  
  This module implements multi-layer (Type-2, see
  [this issue](https://github.com/pytorch/pytorch/issues/4930#issuecomment-361851298))
  bi-directional sequential model based on abstract cell.
  Cell should be a subclass of ``DPRNNCellBase``.
  
  Limitations:
  - proj_size > 0 is not implemented
  - this implementation doesn't use cuDNN
class_docstr_tok: ["Base","class","for","all","RNN-like","sequence","models",".","DP-friendly","drop-in","replacement","of","the","``","torch.nn.RNNBase","``","module",".","After","training","this","module","can","be","exported","and","loaded","by","the","original","``","torch.nn","``","implementation","for","inference",".","This","module","implements","multi-layer","(","Type-2",",","see","[","this","issue","]","(","https",":","\/\/github.com\/pytorch\/pytorch\/issues\/4930","#","issuecomment-361851298",")",")","bi-directional","sequential","model","based","on","abstract","cell",".","Cell","should","be","a","subclass","of","``","DPRNNCellBase","``",".","Limitations",":","-","proj_size",">","0","is","not","implemented","-","this","implementation","does","n't","use","cuDNN"]
code: def __init__(
      self,
      mode: Union[str, Type[DPRNNCellBase]],
      input_size: int,
      hidden_size: int,
      num_layers: int = 1,
      bias: bool = True,
      batch_first: bool = False,
      dropout: float = 0.0,
      bidirectional: bool = False,
      proj_size: int = 0,
      cell_params: Optional[dict] = None,
  ) -> None:
      super().__init__()
  
      self.cell_params = {}
      if isinstance(mode, str):
          if mode not in RNN_CELL_TYPES:
              raise ValueError(
                  f"Invalid RNN mode '{mode}', available options: {list(RNN_CELL_TYPES.keys())}"
              )
          self.cell_type, default_params = RNN_CELL_TYPES[mode]
          self.cell_params.update(default_params)
      else:
          self.cell_type = mode
      if cell_params is not None:
          self.cell_params.update(cell_params)
      self.has_cell_state = self.cell_type.has_cell_state
  
      self.input_size = input_size
      self.hidden_size = hidden_size
      self.num_layers = num_layers
      self.bias = bias
      self.batch_first = batch_first
      self.dropout = float(dropout)
      self.bidirectional = bidirectional
      self.proj_size = proj_size
      self.num_directions = 2 if bidirectional else 1
  
      if (
          not isinstance(dropout, numbers.Number)
          or not 0 <= dropout <= 1
          or isinstance(dropout, bool)
      ):
          raise ValueError(
              "dropout should be a number in range [0, 1] "
              "representing the probability of an element being "
              "zeroed"
          )
      if dropout > 0 and num_layers == 1:
          warnings.warn(
              "dropout option adds dropout after all but last "
              "recurrent layer, so non-zero dropout expects "
              "num_layers greater than 1, but got dropout={} and "
              "num_layers={}".format(dropout, num_layers)
          )
  
      if proj_size > 0:
          raise NotImplementedError("proj_size > 0 is not supported")
      if proj_size < 0:
          raise ValueError(
              "proj_size should be a positive integer or zero to disable projections"
          )
      if proj_size >= hidden_size:
          raise ValueError(
              "proj_size has to be smaller than hidden_size"
          )
  
      self.dropout_layer = nn.Dropout(dropout) if dropout > 0 else None
      self.cells = self.initialize_cells()
  
imports: import math
  import numbers
  import warnings
  from typing import List, Optional, Tuple, Type, Union
  import torch
  import torch.nn
  from torch import Tensor
  from torch.nn.utils.rnn import PackedSequence
  from ..utils.packed_sequences import compute_seq_lengths
  from .param_rename import RenameParamsMixin
label_desc: Use image node_id 1 to create a new DPRNNBase object from inherited base classes: RenameParamsMixin, nn with example: obj = DPRNNBase(mode, input_size, hidden_size, num_layers, bias, batch_first, dropout, bidirectional, proj_size, cell_params)