class_docstr: vanilla stacked layer Seq2Seq model.
  
  Parameters
  ----------
  decoder_seq_length: int
      The length of your target sequence
  cell_enc : TensorFlow cell function
      The RNN function cell for your encoder stack, e.g tf.keras.layers.GRUCell
  cell_dec : TensorFlow cell function
      The RNN function cell for your decoder stack, e.g. tf.keras.layers.GRUCell
  n_layer : int
      The number of your RNN layers for both encoder and decoder block
  embedding_layer : tl.Layer
      A embedding layer, e.g. tl.layers.Embedding(vocabulary_size=voc_size, embedding_size=emb_dim)
  name : str
      The model name
  
  Examples
  ---------
  Classify stacked-layer Seq2Seq model, see `chatbot <https://github.com/tensorlayer/seq2seq-chatbot>`__
  
  Returns
  -------
      static stacked-layer Seq2Seq model.
class_docstr_tok: ["vanilla","stacked","layer","Seq2Seq","model",".","Parameters","--","--","--","--","--","decoder_seq_length",":","int","The","length","of","your","target","sequence","cell_enc",":","TensorFlow","cell","function","The","RNN","function","cell","for","your","encoder","stack",",","e.g","tf.keras.layers.GRUCell","cell_dec",":","TensorFlow","cell","function","The","RNN","function","cell","for","your","decoder","stack",",","e.g",".","tf.keras.layers.GRUCell","n_layer",":","int","The","number","of","your","RNN","layers","for","both","encoder","and","decoder","block","embedding_layer",":","tl.Layer","A","embedding","layer",",","e.g",".","tl.layers.Embedding","(","vocabulary_size=voc_size",",","embedding_size=emb_dim",")","name",":","str","The","model","name","Examples","--","--","--","--","-","Classify","stacked-layer","Seq2Seq","model",",","see","`","chatbot","<","https",":","\/\/github.com\/tensorlayer\/seq2seq-chatbot",">","`","__","Returns","--","--","--","-","static","stacked-layer","Seq2Seq","model","."]
docstr: Inference mode
docstr_tok: ["Inference","mode"]
code: def inference(self, encoding, seq_length, start_token, top_n):
      """Inference mode"""
      """
          Parameters
          ----------
          encoding : input tensor
              The source sequences 
          seq_length : int
              The expected length of your predicted sequence.
          start_token : int
              <SOS> : The token of "start of sequence"
          top_n : int
              Random search algorithm based on the top top_n words sorted by the probablity. 
          """
      feed_output = self.embedding_layer(encoding[0])
      state = [None for i in range(self.n_layer)]
  
      for i in range(self.n_layer):
          feed_output, state[i] = self.enc_layers[i](
              feed_output, return_state=True
          )
      batch_size = len(encoding[0].numpy())
      decoding = [[start_token] for i in range(batch_size)]
      feed_output = self.embedding_layer(decoding)
      for i in range(self.n_layer):
          feed_output, state[i] = self.dec_layers[i](
              feed_output, initial_state=state[i], return_state=True
          )
  
      feed_output = self.reshape_layer(feed_output)
      feed_output = self.dense_layer(feed_output)
      feed_output = self.reshape_layer_individual_sequence(feed_output)
      feed_output = tf.argmax(feed_output, -1)
      # [B, 1]
      final_output = feed_output
  
      for i in range(seq_length - 1):
          feed_output = self.embedding_layer(feed_output)
          for i in range(self.n_layer):
              feed_output, state[i] = self.dec_layers[i](
                  feed_output, initial_state=state[i], return_state=True
              )
          feed_output = self.reshape_layer(feed_output)
          feed_output = self.dense_layer(feed_output)
          feed_output = self.reshape_layer_individual_sequence(
              feed_output
          )
          ori_feed_output = feed_output
          if top_n is not None:
              for k in range(batch_size):
                  idx = np.argpartition(ori_feed_output[k][0], -top_n)[
                      -top_n:
                  ]
                  probs = [ori_feed_output[k][0][i] for i in idx]
                  probs = probs / np.sum(probs)
                  feed_output = np.random.choice(idx, p=probs)
                  feed_output = tf.convert_to_tensor(
                      [[feed_output]], dtype=tf.int64
                  )
                  if k == 0:
                      final_output_temp = feed_output
                  else:
                      final_output_temp = tf.concat(
                          [final_output_temp, feed_output], 0
                      )
              feed_output = final_output_temp
          else:
              feed_output = tf.argmax(feed_output, -1)
          final_output = tf.concat([final_output, feed_output], 1)
  
      return final_output, state
  
file_path: TensorLayer/tensorlayer/models/seq2seq.py
imports: import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import Dense, Dropout, Input
  from tensorlayer.layers.core import Layer
  from tensorlayer.models import Model
label_desc: Use image node_id 2 for calling the Seq2seq obj's underlying member method code with example usage: obj.inference(encoding, seq_length, start_token, top_n) and returns: final_output,  state