class_docstr: Tests :class:`~texar.tf.modules.decoders.rnn_decoders.BasicRNNDecoder`.
      
docstr: Compares decoding results with TF built-in decoder.
          
docstr_tok: ["Compares","decoding","results","with","TF","built-in","decoder","."]
code: def test_decode_train_with_tf(self):
      """Compares decoding results with TF built-in decoder."""
      _inputs_placeholder = tf.placeholder(
          tf.int32, [self._batch_size, self._max_time], name="inputs"
      )
      _embedding_placeholder = tf.placeholder(
          tf.float32, [self._vocab_size, self._emb_dim], name="emb"
      )
      inputs = tf.nn.embedding_lookup(
          _embedding_placeholder, _inputs_placeholder
      )
  
      output_layer = tf.layers.Dense(self._vocab_size)
      decoder = BasicRNNDecoder(
          vocab_size=self._vocab_size, output_layer=output_layer
      )
  
      helper_train = get_helper(
          decoder.hparams.helper_train.type,
          inputs=inputs,
          sequence_length=[self._max_time] * self._batch_size,
          **decoder.hparams.helper_train.kwargs.todict(),
      )
  
      outputs, final_state, sequence_lengths = decoder(
          helper=helper_train
      )
  
      tf_helper = tf.contrib.seq2seq.TrainingHelper(
          inputs, [self._max_time] * self._batch_size
      )
  
      tf_decoder = tf.contrib.seq2seq.BasicDecoder(
          decoder.cell,
          tf_helper,
          decoder.cell.zero_state(self._batch_size, tf.float32),
          output_layer=output_layer,
      )
  
      (
          tf_outputs,
          tf_final_state,
          tf_sequence_lengths,
      ) = tf.contrib.seq2seq.dynamic_decode(tf_decoder)
  
      cell_dim = decoder.hparams.rnn_cell.kwargs.num_units
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          inputs_ = np.random.randint(
              self._vocab_size,
              size=(self._batch_size, self._max_time),
              dtype=np.int32,
          )
          embedding_ = np.random.randn(self._vocab_size, self._emb_dim)
  
          outputs_, final_state_, sequence_lengths_ = sess.run(
              [outputs, final_state, sequence_lengths],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.TRAIN,
                  _inputs_placeholder: inputs_,
                  _embedding_placeholder: embedding_,
              },
          )
          self.assertEqual(
              final_state_[0].shape, (self._batch_size, cell_dim)
          )
  
          tf_outputs_, tf_final_state_, tf_sequence_lengths_ = sess.run(
              [tf_outputs, tf_final_state, tf_sequence_lengths],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.TRAIN,
                  _inputs_placeholder: inputs_,
                  _embedding_placeholder: embedding_,
              },
          )
  
          np.testing.assert_array_equal(
              outputs_.logits, tf_outputs_.rnn_output
          )
          np.testing.assert_array_equal(
              outputs_.sample_id, tf_outputs_.sample_id
          )
          np.testing.assert_array_equal(
              final_state_.c, tf_final_state_.c
          )
          np.testing.assert_array_equal(
              final_state_.h, tf_final_state_.h
          )
          np.testing.assert_array_equal(
              sequence_lengths_, tf_sequence_lengths_
          )
  
imports: import numpy
  import tensorflow
  from texar.tf.modules.decoders.rnn_decoders import BasicRNNDecoderOutput
  from texar.tf.modules.decoders.rnn_decoders import BasicRNNDecoder
  from texar.tf.modules.decoders.rnn_decoders import AttentionRNNDecoderOutput
  from texar.tf.modules.decoders.rnn_decoders import AttentionRNNDecoder
  from texar.tf.modules.decoders.rnn_decoder_helpers import get_helper
  from texar.tf import context
label_desc: Use image node_id 5 for calling the BasicRNNDecoderTest obj's underlying member method code with example usage: obj.test_decode_train_with_tf() without return types