code: def AutogradRNN(
      mode,
      input_size,
      hidden_size,
      num_layers=1,
      batch_first=False,
      dropout=0,
      train=True,
      bidirectional=False,
      variable_length=False,
      dropout_state=None,
      flat_weight=None,
      input_quantizers=None,
      weight_quantizers=None,
  ):
      if mode == "RNN_RELU":
          cell = RNNReLUCell
      elif mode == "RNN_TANH":
          cell = RNNTanhCell
      elif mode == "LSTM":
          cell = LSTMCell
      elif mode == "GRU":
          cell = GRUCell
      else:
          raise Exception("Unknown mode: {}".format(mode))
  
      rec_factory = (
          variable_recurrent_factory if variable_length else Recurrent
      )
  
      if bidirectional:
          layer = (rec_factory(cell), rec_factory(cell, reverse=True))
      else:
          layer = (rec_factory(cell),)
  
      func = StackedRNN(
          layer,
          num_layers,
          (mode == "LSTM"),
          dropout=dropout,
          train=train,
      )
  
      def forward(
          input,
          weight,
          hidden,
          batch_sizes,
          input_quantizers,
          weight_quantizers,
      ):
          if batch_first and not variable_length:
              input = input.transpose(0, 1)
  
          nexth, output = func(
              input,
              hidden,
              weight,
              batch_sizes,
              input_quantizers,
              weight_quantizers,
          )
  
          if batch_first and not variable_length:
              output = output.transpose(0, 1)
  
          return output, nexth
  
      return forward
  
file_path: lightseq/lightseq/csrc/pytorch/pytorch_quantization/nn/_functions/quant_rnn.py
imports: import warnings
  from torch.autograd import NestedIOFunction
  from torch.nn import functional
  import torch
  import itertools
  from functools import partial
label_desc: Use image node_id 10 for calling a global function with example usage: AutogradRNN(mode, input_size, hidden_size, num_layers, batch_first, dropout, train, bidirectional, variable_length, dropout_state, flat_weight, input_quantizers, weight_quantizers) and returns: forward, output,  nexth