code: def test_tokenize_detokenize(self):
      def dataset():
          yield "I have a cat."
  
      # Character-level.
      tok_char = list(tf_inputs.tokenize(dataset(), vocab_type="char"))
      self.assertAllEqual(
          tok_char[0], np.array([ord(c) for c in "I have a cat."])
      )
      detok = tf_inputs.detokenize(tok_char[0], vocab_type="char")
      self.assertEqual(detok, "I have a cat.")
  
      # Sentencepiece.
      tok_spc = list(
          tf_inputs.tokenize(
              dataset(),
              vocab_type="sentencepiece",
              vocab_dir=_TESTDATA,
              vocab_file="sentencepiece.model",
          )
      )
      self.assertAllEqual(tok_spc[0], np.array([27, 43, 3, 9, 1712, 5]))
      detok = tf_inputs.detokenize(
          list(tok_spc[0]),
          vocab_type="sentencepiece",
          vocab_dir=_TESTDATA,
          vocab_file="sentencepiece.model",
      )
      self.assertEqual(detok, "I have a cat.")
  
      # Subword.
      tok_sbw = list(
          tf_inputs.tokenize(
              dataset(),
              vocab_type="subword",
              vocab_dir=_TESTDATA,
              vocab_file="en_8k.subword",
          )
      )
      self.assertAllEqual(
          tok_sbw[0], np.array([139, 96, 12, 2217, 2, 21])
      )
      detok = tf_inputs.detokenize(
          tok_sbw[0],
          vocab_type="subword",
          vocab_dir=_TESTDATA,
          vocab_file="en_8k.subword",
      )
      self.assertEqual(detok, "I have a cat.")
  
      # bert-lowercase
      tok_sbw = list(
          tf_inputs.tokenize(
              dataset(),
              vocab_type="bert-lowercase",
              vocab_dir=_TESTDATA,
              vocab_file="bert_uncased_vocab.txt",
          )
      )
      self.assertAllEqual(
          tok_sbw[0], np.array([1045, 2031, 1037, 4937, 1012])
      )
      detok = tf_inputs.detokenize(
          tok_sbw[0],
          vocab_type="bert-lowercase",
          vocab_dir=_TESTDATA,
          vocab_file="bert_uncased_vocab.txt",
      )
      self.assertEqual(detok, "i have a cat .")
  
imports: import collections
  import os
  from unittest import mock
  import gin
  import numpy
  from t5.data import assert_dataset
  from t5.data import preprocessors
  import tensorflow
  import tensorflow_datasets
  from trax.data import inputs
  from trax.data import tf_inputs
label_desc: Use image node_id 7 for calling the TFInputsTest obj's underlying member method code with example usage: obj.test_tokenize_detokenize() without return types