class_docstr: sequence to sequence task test
docstr: test seq to seq task of chiniese data, split sentences by space
docstr_tok: ["test","seq","to","seq","task","of","chiniese","data",",","split","sentences","by","space"]
code: def test_english(self):
      """test seq to seq task of chiniese data, split sentences by space"""
  
      config = utils.load_config(self.config_file)
      max_len = config["model"]["net"]["structure"]["max_enc_len"]
      data_config = config["data"]
      task_config = data_config["task"]
      task_config["language"] = "english"
      task_config["split_by_space"] = False
      task_config["use_word"] = True
  
      # test offline data for 'train'
  
      task = TextS2STask(config, utils.TRAIN)
      data = task.dataset()
      self.assertTrue(
          "input_x_dict" in data
          and "input_enc_x" in data["input_x_dict"]
          and "input_dec_x" in data["input_x_dict"]
      )
      self.assertTrue(
          "input_y_dict" in data and "input_y" in data["input_y_dict"]
      )
      with self.cached_session(use_gpu=False, force_gpu=False) as sess:
          sess.run(data["iterator"].initializer)
          res = sess.run(
              [
                  data["input_x_dict"]["input_enc_x"],
                  data["input_x_dict"]["input_dec_x"],
                  data["input_y_dict"]["input_y"],
                  data["input_x_len"],
              ]
          )
  
          logging.debug(res[0][0])
          logging.debug(res[1][0])
          logging.debug(res[2][0])
          logging.debug(res[3])
  
          self.assertEqual(np.shape(res[0])[0], 16)
          self.assertEqual(np.shape(res[1])[0], 16)
          self.assertEqual(np.shape(res[2])[0], 16)
          self.assertEqual(np.shape(res[3])[0], 16)
  
      # test offline data for 'infer'
      task = TextS2STask(config, utils.INFER)
      task.infer_without_label = True
      data = task.dataset()
      self.assertTrue(
          "input_x_dict" in data
          and "input_enc_x" in data["input_x_dict"]
      )
      with self.cached_session(use_gpu=False, force_gpu=False) as sess:
          sess.run(data["iterator"].initializer)
          res = sess.run(
              [data["input_x_dict"]["input_enc_x"], data["input_x_len"]]
          )
  
          logging.debug(res[0][0])
          logging.debug(res[1][0])
  
          self.assertEqual(np.shape(res[0])[0], 16)
          self.assertEqual(np.shape(res[1])[0], 16)
  
      # test online data
      export_inputs = task.export_inputs()
      self.assertTrue(
          "export_inputs" in export_inputs
          and "input_sentence" in export_inputs["export_inputs"]
      )
      input_sentence = export_inputs["export_inputs"]["input_sentence"]
      input_x = export_inputs["model_inputs"]["input_enc_x"]
  
      with self.cached_session(use_gpu=False, force_gpu=False) as sess:
          sess.run(data["iterator"].initializer)
          res = sess.run(
              input_x,
              feed_dict={
                  input_sentence: [
                      " vice president walter " "mondale was released"
                  ]
              },
          )
          logging.debug(res[0][:5])
          logging.debug(np.shape(res[0]))
          self.assertEqual(np.shape(res[0]), (max_len,))
  
file_path: delta/delta/data/task/text_seq2seq_task_test.py
imports: import os
  from pathlib import Path
  import numpy
  import delta.compat
  from absl import logging
  from delta import utils
  from delta import PACKAGE_ROOT_DIR
  from delta.data.task.text_seq2seq_task import TextS2STask
  from delta.utils.register import import_all_modules_for_register
label_desc: Use image node_id 3 for calling the TextS2STaskTest obj's underlying member method code with example usage: obj.test_english() without return types