class_docstr: A text dataset with one sequence as input and a label.
class_docstr_tok: ["A","text","dataset","with","one","sequence","as","input","and","a","label","."]
docstr: Prepares an example by converting text to token IDs.
docstr_tok: ["Prepares","an","example","by","converting","text","to","token","IDs","."]
code: def prepare_example(self, example: Example) -> Example:
      """Prepares an example by converting text to token IDs."""
      tokens = self.tokenizer.tokenize(example[self.text_feature_name])
      label = example[self.label_feature_name]
      del example[self.text_feature_name]
      del example[self.label_feature_name]
      example["token_ids"] = self.add_bos_eos(
          self.tf_vocab.lookup(tokens)
      )
      example["length"] = tf.size(example["token_ids"])
      example["label"] = label
      return example
  
imports: from typing import Any, Dict, Optional
  from absl import logging
  import numpy
  import tensorflow
  import tensorflow_datasets
  import tensorflow_text
  import vocabulary
label_desc: Use image node_id 5 for calling the TextDataset obj's underlying member method code with example usage: obj.prepare_example(example) and returns: example