class_docstr: Tests text data class.
      
code: def _run_and_test(
      self, hparams, test_batch_size=False, length_inc=None
  ):
      # Construct database
      text_data = tx.data.MonoTextData(hparams)
      self.assertEqual(
          text_data.vocab.size,
          self._vocab_size + len(text_data.vocab.special_tokens),
      )
  
      iterator = text_data.dataset.make_initializable_iterator()
      text_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())
          sess.run(iterator.initializer)
  
          while True:
              try:
                  data_batch_ = sess.run(text_data_batch)
  
                  self.assertEqual(
                      set(data_batch_.keys()),
                      set(text_data.list_items()),
                  )
  
                  if test_batch_size:
                      self.assertEqual(
                          len(data_batch_["text"]),
                          hparams["batch_size"],
                      )
  
                  if length_inc:
                      for i in range(len(data_batch_["text"])):
                          text_ = data_batch_["text"][i].tolist()
                          self.assertEqual(
                              text_.index(b"<EOS>") + 1,
                              data_batch_["length"][i] - length_inc,
                          )
  
                  max_seq_length = (
                      text_data.hparams.dataset.max_seq_length
                  )
                  mode = text_data.hparams.dataset.length_filter_mode
                  if max_seq_length == 6:
                      max_l = max_seq_length
                      max_l += text_data._decoder.added_length
                      for length in data_batch_["length"]:
                          self.assertLessEqual(length, max_l)
                      if mode == "discard":
                          for length in data_batch_["length"]:
                              self.assertEqual(length, 5)
                      elif mode == "truncate":
                          num_length_6 = 0
                          for length in data_batch_["length"]:
                              num_length_6 += int(length == 6)
                          self.assertGreater(num_length_6, 0)
                      else:
                          raise ValueError("Unknown mode: %s" % mode)
  
                  if text_data.hparams.dataset.pad_to_max_seq_length:
                      max_l = (
                          max_seq_length
                          + text_data._decoder.added_length
                      )
                      for x in data_batch_["text"]:
                          self.assertEqual(len(x), max_l)
                      for x in data_batch_["text_ids"]:
                          self.assertEqual(len(x), max_l)
  
              except tf.errors.OutOfRangeError:
                  print("Done -- epoch limit reached")
                  break
  
imports: import tempfile
  import copy
  import numpy
  import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling the MonoTextDataTest obj's underlying member method code with example usage: obj._run_and_test(hparams, test_batch_size, length_inc) without return types