class_docstr: A hierarchical encoder that stacks basic RNN encoders into two layers.
  Can be used to encode long, structured sequences, e.g. paragraphs, dialog
  history, etc.
  
  Args:
      encoder_major (optional): An instance of subclass of
          :class:`~texar.tf.modules.RNNEncoderBase`
          The high-level encoder taking final
          states from low-level encoder as its
          inputs. If not specified, an encoder
          is created as specified in
          :attr:`hparams["encoder_major"]`.
      encoder_minor (optional): An instance of subclass of
          :class:`~texar.tf.modules.RNNEncoderBase`
          The low-level encoder. If not
          specified, an encoder is created as specified
          in :attr:`hparams["encoder_minor"]`.
      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.
  
  .. document private functions
  .. automethod:: _build
docstr: Flattens a cell state by concatenating a sequence of cell
  states along the last dimension. If the cell states are
  :tf_main:`LSTMStateTuple <contrib/rnn/LSTMStateTuple>`, only the
  hidden `LSTMStateTuple.h` is used.
  
  This process is used by default if :attr:`medium` is not provided
  to :meth:`_build`.
docstr_tok: ["Flattens","a","cell","state","by","concatenating","a","sequence","of","cell","states","along","the","last","dimension",".","If","the","cell","states","are",":","tf_main",":","`","LSTMStateTuple","<","contrib\/rnn\/LSTMStateTuple",">","`",",","only","the","hidden","`","LSTMStateTuple.h","`","is","used",".","This","process","is","used","by","default","if",":","attr",":","`","medium","`","is","not","provided","to",":","meth",":","`","_build","`","."]
code: def flatten(x):
      """Flattens a cell state by concatenating a sequence of cell
      states along the last dimension. If the cell states are
      :tf_main:`LSTMStateTuple <contrib/rnn/LSTMStateTuple>`, only the
      hidden `LSTMStateTuple.h` is used.
  
      This process is used by default if :attr:`medium` is not provided
      to :meth:`_build`.
      """
      if isinstance(x, LSTMStateTuple):
          return x.h
      if isinstance(x, collections.Sequence):
          return tf.concat(
              [HierarchicalRNNEncoder.flatten(v) for v in x], -1
          )
      else:
          return x
  
file_path: texar/texar/tf/modules/encoders/hierarchical_encoders.py
imports: import collections
  import tensorflow
  from tensorflow.contrib.rnn import LSTMStateTuple
  from tensorflow.python.util import nest
  from texar.tf.modules.encoders.encoder_base import EncoderBase
  from texar.tf.utils import utils
label_desc: Use image node_id 6 for calling the HierarchicalRNNEncoder obj's underlying member method code with example usage: obj.flatten(x) and returns: x, tf, x