class_docstr: Tests :class:`~texar.tf.modules.decoders.rnn_decoders.AttentionRNNDecoder`.
      
docstr: Tests decoding in inference mode.
          
docstr_tok: ["Tests","decoding","in","inference","mode","."]
code: def test_decode_infer(self):
      """Tests decoding in inference mode."""
      seq_length = (
          np.random.randint(self._max_time, size=[self._batch_size]) + 1
      )
      encoder_values_length = tf.constant(seq_length)
      hparams = {
          "attention": {
              "kwargs": {
                  "num_units": 256,
              }
          }
      }
      decoder = AttentionRNNDecoder(
          vocab_size=self._vocab_size,
          memory=self._encoder_output,
          memory_sequence_length=encoder_values_length,
          hparams=hparams,
      )
  
      helper_infer = get_helper(
          decoder.hparams.helper_infer.type,
          embedding=self._embedding,
          start_tokens=[1] * self._batch_size,
          end_token=2,
          **decoder.hparams.helper_train.kwargs.todict(),
      )
  
      outputs, final_state, sequence_lengths = decoder(
          helper=helper_infer
      )
  
      # 4+1 trainable variables: cell-kernel, cell-bias,
      # fc-weight, fc-bias, and
      # memory_layer: For LuongAttention, we only transform the memory layer;
      # thus num_units *must* match the expected query depth.
      self.assertEqual(len(decoder.trainable_variables), 5)
      cell_dim = decoder.hparams.rnn_cell.kwargs.num_units
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          outputs_, final_state_, sequence_lengths_ = sess.run(
              [outputs, final_state, sequence_lengths],
              feed_dict={
                  context.global_mode(): tf.estimator.ModeKeys.PREDICT
              },
          )
          self.assertIsInstance(outputs_, AttentionRNNDecoderOutput)
          max_length = max(sequence_lengths_)
          self.assertEqual(
              outputs_.logits.shape,
              (self._batch_size, max_length, self._vocab_size),
          )
          self.assertEqual(
              outputs_.sample_id.shape, (self._batch_size, max_length)
          )
          self.assertEqual(
              final_state_.cell_state[0].shape,
              (self._batch_size, cell_dim),
          )
  
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 3 for calling the AttentionRNNDecoderTest obj's underlying member method code with example usage: obj.test_decode_infer() without return types