class_docstr: Bidirectional forward-backward RNN encoder.
  
  Args:
      cell_fw (RNNCell, optional): The forward RNN cell. If not given,
          a cell is created as specified in :attr:`hparams["rnn_cell_fw"]`.
      cell_bw (RNNCell, optional): The backward RNN cell. If not given,
          a cell is created as specified in :attr:`hparams["rnn_cell_bw"]`.
      cell_dropout_mode (optional): A tensor taking value of
          :tf_main:`tf.estimator.ModeKeys <estimator/ModeKeys>`, which
          toggles dropout in the RNN cells (e.g., activates dropout in
          TRAIN mode). If `None`, :func:`~texar.tf.global_mode()` is
          used. Ignored if respective cell is given.
      output_layer_fw (optional): An instance of
          :tf_main:`tf.layers.Layer <layers/Layer>`. Apply to the forward
          RNN cell output of each step. If `None` (default), the output
          layer is created as specified in :attr:`hparams["output_layer_fw"]`.
      output_layer_bw (optional): An instance of
          :tf_main:`tf.layers.Layer <layers/Layer>`. Apply to the backward
          RNN cell output of each step. If `None` (default), the output
          layer is created as specified in :attr:`hparams["output_layer_bw"]`.
      hparams (dict or HParams, optional): Hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter sturcture and
          default values.
  
  See :meth:`_build` for the inputs and outputs of the encoder.
  
  Example:
  
      .. code-block:: python
  
          # Use with embedder
          embedder = WordEmbedder(vocab_size, hparams=emb_hparams)
          encoder = BidirectionalRNNEncoder(hparams=enc_hparams)
  
          outputs, final_state = encoder(
              inputs=embedder(data_batch['text_ids']),
              sequence_length=data_batch['length'])
          # outputs == (outputs_fw, outputs_bw)
          # final_state == (final_state_fw, final_state_bw)
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Bidirectional","forward-backward","RNN","encoder",".","Args",":","cell_fw","(","RNNCell",",","optional",")",":","The","forward","RNN","cell",".","If","not","given",",","a","cell","is","created","as","specified","in",":","attr",":","`","hparams","[","``","rnn_cell_fw","''","]","`",".","cell_bw","(","RNNCell",",","optional",")",":","The","backward","RNN","cell",".","If","not","given",",","a","cell","is","created","as","specified","in",":","attr",":","`","hparams","[","``","rnn_cell_bw","''","]","`",".","cell_dropout_mode","(","optional",")",":","A","tensor","taking","value","of",":","tf_main",":","`","tf.estimator.ModeKeys","<","estimator\/ModeKeys",">","`",",","which","toggles","dropout","in","the","RNN","cells","(","e.g.",",","activates","dropout","in","TRAIN","mode",")",".","If","`","None","`",",",":","func",":","`","~texar.tf.global_mode","(",")","`","is","used",".","Ignored","if","respective","cell","is","given",".","output_layer_fw","(","optional",")",":","An","instance","of",":","tf_main",":","`","tf.layers.Layer","<","layers\/Layer",">","`",".","Apply","to","the","forward","RNN","cell","output","of","each","step",".","If","`","None","`","(","default",")",",","the","output","layer","is","created","as","specified","in",":","attr",":","`","hparams","[","``","output_layer_fw","''","]","`",".","output_layer_bw","(","optional",")",":","An","instance","of",":","tf_main",":","`","tf.layers.Layer","<","layers\/Layer",">","`",".","Apply","to","the","backward","RNN","cell","output","of","each","step",".","If","`","None","`","(","default",")",",","the","output","layer","is","created","as","specified","in",":","attr",":","`","hparams","[","``","output_layer_bw","''","]","`",".","hparams","(","dict","or","HParams",",","optional",")",":","Hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","sturcture","and","default","values",".","See",":","meth",":","`","_build","`","for","the","inputs","and","outputs","of","the","encoder",".","Example",":","..","code-block",":",":","python","#","Use","with","embedder","embedder","=","WordEmbedder","(","vocab_size",",","hparams=emb_hparams",")","encoder","=","BidirectionalRNNEncoder","(","hparams=enc_hparams",")","outputs",",","final_state","=","encoder","(","inputs=embedder","(","data_batch","[","'text_ids","'","]",")",",","sequence_length=data_batch","[","'length","'","]",")","#","outputs","==","(","outputs_fw",",","outputs_bw",")","#","final_state","==","(","final_state_fw",",","final_state_bw",")","..","document","private","functions","..","automethod",":",":","_build"]
docstr: Returns a dictionary of hyperparameters with default values.
  
  .. code-block:: python
  
      {
          "rnn_cell_fw": default_rnn_cell_hparams(),
          "rnn_cell_bw": default_rnn_cell_hparams(),
          "rnn_cell_share_config": True,
          "output_layer_fw": {
              "num_layers": 0,
              "layer_size": 128,
              "activation": "identity",
              "final_layer_activation": None,
              "other_dense_kwargs": None,
              "dropout_layer_ids": [],
              "dropout_rate": 0.5,
              "variational_dropout": False
          },
          "output_layer_bw": {
              # Same hyperparams and default values as "output_layer_fw"
              # ...
          },
          "output_layer_share_config": True,
          "name": "bidirectional_rnn_encoder"
      }
  
  Here:
  
  "rnn_cell_fw": dict
      Hyperparameters of the forward RNN cell.
      Ignored if :attr:`cell_fw` is given to the encoder constructor.
  
      The default value is defined in
      :func:`~texar.tf.core.default_rnn_cell_hparams`.
  
  "rnn_cell_bw": dict
      Hyperparameters of the backward RNN cell.
      Ignored if :attr:`cell_bw` is given to the encoder constructor
      , or if :attr:`"rnn_cell_share_config"` is `True`.
  
      The default value is defined in
      :meth:`~texar.tf.core.default_rnn_cell_hparams`.
  
  "rnn_cell_share_config": bool
      Whether share hyperparameters of the backward cell with the
      forward cell. Note that the cell parameters (variables) are not
      shared.
  
  "output_layer_fw": dict
      Hyperparameters of the forward output layer. Ignored if
      :attr:`output_layer_fw` is given to the constructor.
      See the "output_layer" field of
      :meth:`~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams` for
      details.
  
  "output_layer_bw": dict
      Hyperparameters of the backward output layer. Ignored if
      :attr:`output_layer_bw` is given to the constructor. Have the
      same structure and defaults with :attr:`"output_layer_fw"`.
  
      Ignored if :attr:`"output_layer_share_config"` is True.
  
  "output_layer_share_config": bool
      Whether share hyperparameters of the backward output layer
      with the forward output layer. Note that the layer parameters
      (variables) are not shared.
  
  "name": str
      Name of the encoder
docstr_tok: ["Returns","a","dictionary","of","hyperparameters","with","default","values",".","..","code-block",":",":","python","{","``","rnn_cell_fw","''",":","default_rnn_cell_hparams","(",")",",","``","rnn_cell_bw","''",":","default_rnn_cell_hparams","(",")",",","``","rnn_cell_share_config","''",":","True",",","``","output_layer_fw","''",":","{","``","num_layers","''",":","0",",","``","layer_size","''",":","128",",","``","activation","''",":","``","identity","''",",","``","final_layer_activation","''",":","None",",","``","other_dense_kwargs","''",":","None",",","``","dropout_layer_ids","''",":","[","]",",","``","dropout_rate","''",":","0.5",",","``","variational_dropout","''",":","False","}",",","``","output_layer_bw","''",":","{","#","Same","hyperparams","and","default","values","as","``","output_layer_fw","''","#","...","}",",","``","output_layer_share_config","''",":","True",",","``","name","''",":","``","bidirectional_rnn_encoder","''","}","Here",":","''","rnn_cell_fw","''",":","dict","Hyperparameters","of","the","forward","RNN","cell",".","Ignored","if",":","attr",":","`","cell_fw","`","is","given","to","the","encoder","constructor",".","The","default","value","is","defined","in",":","func",":","`","~texar.tf.core.default_rnn_cell_hparams","`",".","``","rnn_cell_bw","''",":","dict","Hyperparameters","of","the","backward","RNN","cell",".","Ignored","if",":","attr",":","`","cell_bw","`","is","given","to","the","encoder","constructor",",","or","if",":","attr",":","`","``","rnn_cell_share_config","''","`","is","`","True","`",".","The","default","value","is","defined","in",":","meth",":","`","~texar.tf.core.default_rnn_cell_hparams","`",".","``","rnn_cell_share_config","''",":","bool","Whether","share","hyperparameters","of","the","backward","cell","with","the","forward","cell",".","Note","that","the","cell","parameters","(","variables",")","are","not","shared",".","``","output_layer_fw","''",":","dict","Hyperparameters","of","the","forward","output","layer",".","Ignored","if",":","attr",":","`","output_layer_fw","`","is","given","to","the","constructor",".","See","the","``","output_layer","''","field","of",":","meth",":","`","~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams","`","for","details",".","``","output_layer_bw","''",":","dict","Hyperparameters","of","the","backward","output","layer",".","Ignored","if",":","attr",":","`","output_layer_bw","`","is","given","to","the","constructor",".","Have","the","same","structure","and","defaults","with",":","attr",":","`","``","output_layer_fw","''","`",".","Ignored","if",":","attr",":","`","``","output_layer_share_config","''","`","is","True",".","``","output_layer_share_config","''",":","bool","Whether","share","hyperparameters","of","the","backward","output","layer","with","the","forward","output","layer",".","Note","that","the","layer","parameters","(","variables",")","are","not","shared",".","``","name","''",":","str","Name","of","the","encoder"]
code: def default_hparams():
      """Returns a dictionary of hyperparameters with default values.
  
      .. code-block:: python
  
          {
              "rnn_cell_fw": default_rnn_cell_hparams(),
              "rnn_cell_bw": default_rnn_cell_hparams(),
              "rnn_cell_share_config": True,
              "output_layer_fw": {
                  "num_layers": 0,
                  "layer_size": 128,
                  "activation": "identity",
                  "final_layer_activation": None,
                  "other_dense_kwargs": None,
                  "dropout_layer_ids": [],
                  "dropout_rate": 0.5,
                  "variational_dropout": False
              },
              "output_layer_bw": {
                  # Same hyperparams and default values as "output_layer_fw"
                  # ...
              },
              "output_layer_share_config": True,
              "name": "bidirectional_rnn_encoder"
          }
  
      Here:
  
      "rnn_cell_fw": dict
          Hyperparameters of the forward RNN cell.
          Ignored if :attr:`cell_fw` is given to the encoder constructor.
  
          The default value is defined in
          :func:`~texar.tf.core.default_rnn_cell_hparams`.
  
      "rnn_cell_bw": dict
          Hyperparameters of the backward RNN cell.
          Ignored if :attr:`cell_bw` is given to the encoder constructor
          , or if :attr:`"rnn_cell_share_config"` is `True`.
  
          The default value is defined in
          :meth:`~texar.tf.core.default_rnn_cell_hparams`.
  
      "rnn_cell_share_config": bool
          Whether share hyperparameters of the backward cell with the
          forward cell. Note that the cell parameters (variables) are not
          shared.
  
      "output_layer_fw": dict
          Hyperparameters of the forward output layer. Ignored if
          :attr:`output_layer_fw` is given to the constructor.
          See the "output_layer" field of
          :meth:`~texar.tf.modules.UnidirectionalRNNEncoder.default_hparams` for
          details.
  
      "output_layer_bw": dict
          Hyperparameters of the backward output layer. Ignored if
          :attr:`output_layer_bw` is given to the constructor. Have the
          same structure and defaults with :attr:`"output_layer_fw"`.
  
          Ignored if :attr:`"output_layer_share_config"` is True.
  
      "output_layer_share_config": bool
          Whether share hyperparameters of the backward output layer
          with the forward output layer. Note that the layer parameters
          (variables) are not shared.
  
      "name": str
          Name of the encoder
      """
      hparams = RNNEncoderBase.default_hparams()
      hparams.update(
          {
              "rnn_cell_fw": layers.default_rnn_cell_hparams(),
              "rnn_cell_bw": layers.default_rnn_cell_hparams(),
              "rnn_cell_share_config": True,
              "output_layer_fw": _default_output_layer_hparams(),
              "output_layer_bw": _default_output_layer_hparams(),
              "output_layer_share_config": True,
              "name": "bidirectional_rnn_encoder",
          }
      )
      return hparams
  
imports: import functools
  import numpy
  import tensorflow
  from tensorflow.contrib.framework import nest
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.modules.networks.conv_networks import _to_list
  from texar.tf.core import layers
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.utils.shapes import mask_sequences
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 2 for calling the BidirectionalRNNEncoder obj's underlying member method code with example usage: obj.default_hparams() and returns: hparams