code: def __init__(
      self,
      mode,
      input_size,
      hidden_size,
      num_layers=1,
      bias=True,
      batch_first=False,
      dropout=0,
      bidirectional=False,
      proj_size=0,
      **kwargs,
  ):
      super(QuantRNNBase, self).__init__()
      self.mode = mode
      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 = dropout
      self.dropout_state = {}
      self.bidirectional = bidirectional
      self.proj_size = proj_size
      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 ValueError(
              "proj_size should be a positive integer or zero to disable projections"
          )
      if proj_size > 0:
          raise ValueError(
              "proj_size is not supported in pytorch-quantization yet"
          )
  
      if mode == "LSTM":
          gate_size = 4 * hidden_size
      elif mode == "GRU":
          gate_size = 3 * hidden_size
      else:
          gate_size = hidden_size
  
      self._all_weights = []
      for layer in range(num_layers):
          for direction in range(num_directions):
              layer_input_size = (
                  input_size
                  if layer == 0
                  else hidden_size * num_directions
              )
  
              w_ih = Parameter(
                  torch.Tensor(gate_size, layer_input_size)
              )
              w_hh = Parameter(torch.Tensor(gate_size, hidden_size))
              b_ih = Parameter(torch.Tensor(gate_size))
              b_hh = Parameter(torch.Tensor(gate_size))
              layer_params = (w_ih, w_hh, b_ih, b_hh)
  
              suffix = "_reverse" if direction == 1 else ""
              param_names = ["weight_ih_l{}{}", "weight_hh_l{}{}"]
              if bias:
                  param_names += ["bias_ih_l{}{}", "bias_hh_l{}{}"]
              param_names = [
                  x.format(layer, suffix) for x in param_names
              ]
  
              for name, param in zip(param_names, layer_params):
                  setattr(self, name, param)
              self._all_weights.append(param_names)
  
      self.flatten_parameters()
      self.reset_parameters()
  
      (
          quant_desc_input,
          quant_desc_weight,
      ) = _utils.pop_quant_desc_in_kwargs(self.__class__, **kwargs)
      self.init_quantizer(
          quant_desc_input,
          quant_desc_weight,
          num_layers=num_layers * (1 + bidirectional),
      )
  
imports: import math
  import torch
  import warnings
  import itertools
  import numbers
  from torch import nn
  from torch.nn import Parameter
  from torch.nn.utils.rnn import PackedSequence
  from lightseq.training.pytorch_quantization import tensor_quant
  from lightseq.training.pytorch_quantization.nn._functions import quant_rnn
  from .None import _utils
label_desc: Use image node_id 1 to create a new QuantRNNBase object from inherited base classes: nn, _utils with example: obj = QuantRNNBase(mode, input_size, hidden_size, num_layers, bias, batch_first, dropout, bidirectional, proj_size)