class_docstr: Tests the ParallelDataProvider class
    
class_docstr_tok: ["Tests","the","ParallelDataProvider","class"]
code: def test_reading(self):
      num_epochs = 50
      data_provider = make_parallel_data_provider(
          data_sources_source=[self.source_file.name],
          data_sources_target=[self.target_file.name],
          num_epochs=num_epochs,
          shuffle=True,
      )
  
      item_keys = list(data_provider.list_items())
      item_values = data_provider.get(item_keys)
      items_dict = dict(zip(item_keys, item_values))
  
      self.assertEqual(
          set(item_keys),
          set(
              [
                  "source_tokens",
                  "source_len",
                  "target_tokens",
                  "target_len",
              ]
          ),
      )
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          sess.run(tf.local_variables_initializer())
          with tf.contrib.slim.queues.QueueRunners(sess):
              item_dicts_ = [
                  sess.run(items_dict) for _ in range(num_epochs * 3)
              ]
  
      for item_dict in item_dicts_:
          item_dict["target_tokens"] = np.char.decode(
              item_dict["target_tokens"].astype("S"), "utf-8"
          )
          item_dict["source_tokens"] = np.char.decode(
              item_dict["source_tokens"].astype("S"), "utf-8"
          )
  
          # Source is Data + SEQUENCE_END
          self.assertEqual(item_dict["source_len"], 2)
          self.assertEqual(
              item_dict["source_tokens"][-1], "SEQUENCE_END"
          )
          # Target is SEQUENCE_START + Data + SEQUENCE_END
          self.assertEqual(item_dict["target_len"], 3)
          self.assertEqual(
              item_dict["target_tokens"][0], "SEQUENCE_START"
          )
          self.assertEqual(
              item_dict["target_tokens"][-1], "SEQUENCE_END"
          )
  
          # Make sure data is aligned
          source_joined = " ".join(item_dict["source_tokens"][:-1])
          expected_target = self.source_to_target[source_joined]
          np.testing.assert_array_equal(
              item_dict["target_tokens"],
              ["SEQUENCE_START"]
              + expected_target.split(" ")
              + ["SEQUENCE_END"],
          )
  
file_path: seq2seq/seq2seq/test/data_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import tempfile
  import tensorflow
  import numpy
  from seq2seq.data import split_tokens_decoder
  from seq2seq.data.parallel_data_provider import make_parallel_data_provider
label_desc: Use image node_id 3 for calling the ParallelDataProviderTest obj's underlying member method code with example usage: obj.test_reading() without return types