class_docstr: Tests data iterators.
      
class_docstr_tok: ["Tests","data","iterators","."]
docstr: Tests :class:`texar.tf.data.TrainTestDataIterator`
          
docstr_tok: ["Tests",":","class",":","`","texar.tf.data.TrainTestDataIterator","`"]
code: def test_train_test_data_iterator(self):
      """Tests :class:`texar.tf.data.TrainTestDataIterator`"""
      train_data = tx.data.MonoTextData(self._train_hparams)
      test_data = tx.data.MonoTextData(self._test_hparams)
  
      iterator = tx.data.TrainTestDataIterator(
          train=train_data, test=test_data
      )
      data_batch = iterator.get_next()
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          sess.run(tf.local_variables_initializer())
          sess.run(tf.tables_initializer())
  
          for _ in range(2):
              iterator.switch_to_train_data(sess)
              i = 0
              while True:
                  try:
                      data_batch_ = sess.run(data_batch)
                      self.assertEqual(
                          tf.compat.as_text(data_batch_["text"][0][0]),
                          str(i + 1),
                      )
                      i = (i + 1) % 1000
                  except tf.errors.OutOfRangeError:
                      print("Train data limit reached")
                      self.assertEqual(i, 0)
                      break
  
              iterator.switch_to_test_data(sess)
              i = 1001
              while True:
                  try:
                      data_batch_ = sess.run(data_batch)
                      self.assertEqual(
                          tf.compat.as_text(data_batch_["text"][0][0]),
                          str(i),
                      )
                      i += 1
                  except tf.errors.OutOfRangeError:
                      print("Test data limit reached")
                      self.assertEqual(i, 2001)
                      break
  
file_path: texar/tests/data/data/data_iterators_test.py
imports: import tempfile
  import numpy
  import tensorflow
  import texar.tf
label_desc: Use image node_id 4 for calling the DataIteratorTest obj's underlying member method code with example usage: obj.test_train_test_data_iterator() without return types