code: def test_basic_simpleSeq2Seq(self):
      model_ = Seq2seq(
          decoder_seq_length=5,
          cell_enc=tf.keras.layers.GRUCell,
          cell_dec=tf.keras.layers.GRUCell,
          n_layer=3,
          n_units=128,
          embedding_layer=tl.layers.Embedding(
              vocabulary_size=self.vocab_size,
              embedding_size=self.embedding_size,
          ),
      )
  
      optimizer = tf.optimizers.Adam(learning_rate=0.001)
  
      for epoch in range(self.num_epochs):
          model_.train()
          trainX, trainY = shuffle(self.trainX, self.trainY)
          total_loss, n_iter = 0, 0
          for X, Y in tqdm(
              tl.iterate.minibatches(
                  inputs=trainX,
                  targets=trainY,
                  batch_size=self.batch_size,
                  shuffle=False,
              ),
              total=self.n_step,
              desc="Epoch[{}/{}]".format(epoch + 1, self.num_epochs),
              leave=False,
          ):
              dec_seq = Y[:, :-1]
              target_seq = Y[:, 1:]
  
              with tf.GradientTape() as tape:
                  ## compute outputs
                  output = model_(inputs=[X, dec_seq])
  
                  output = tf.reshape(output, [-1, self.vocab_size])
  
                  loss = cross_entropy_seq(
                      logits=output, target_seqs=target_seq
                  )
  
                  grad = tape.gradient(loss, model_.all_weights)
                  optimizer.apply_gradients(
                      zip(grad, model_.all_weights)
                  )
  
              total_loss += loss
              n_iter += 1
  
          model_.eval()
          test_sample = trainX[0:2, :].tolist()
  
          top_n = 1
          for i in range(top_n):
              prediction = model_(
                  [test_sample],
                  seq_length=self.dec_seq_length,
                  start_token=0,
                  top_n=1,
              )
              print(
                  "Prediction: >>>>>  ",
                  prediction,
                  "\n Target: >>>>>  ",
                  trainY[0:2, 1:],
                  "\n\n",
              )
  
          # printing average loss after every epoch
          print(
              "Epoch [{}/{}]: loss {:.4f}".format(
                  epoch + 1, self.num_epochs, total_loss / n_iter
              )
          )
  
file_path: TensorLayer/tests/models/test_seq2seq_model.py
imports: import os
  import unittest
  import numpy
  import tensorflow
  from sklearn.utils import shuffle
  from tqdm import tqdm
  import tensorlayer
  from tensorlayer.cost import cross_entropy_seq
  from tensorlayer.models.seq2seq import Seq2seq
  from tests.utils import CustomTestCase
label_desc: Use image node_id 3 for calling the Model_SEQ2SEQ_Test obj's underlying member method code with example usage: obj.test_basic_simpleSeq2Seq() without return types