code: def pretokenized_tfds_dataset(
      dataset_name=gin.REQUIRED,
      text2self=gin.REQUIRED,
      tfds_data_dir=gin.REQUIRED,
      dataset_split=gin.REQUIRED,
      batch_size=None,
      sequence_length=gin.REQUIRED,
      vocabulary=None,
  ):
      """Reads a tensorflow_datasets dataset.
  
      Args:
        dataset_name: a string
        text2self: a boolean
        tfds_data_dir: a boolean
        dataset_split: a string
        batch_size: an integer, DEPRECATED
        sequence_length: an integer
        vocabulary: ignored
      Returns:
        a tf.data.Dataset of batches
      """
      del batch_size
      del vocabulary
      dataset = tfds.load(
          dataset_name,
          split=dataset_split,
          as_supervised=True,
          data_dir=tfds_data_dir,
          shuffle_files=dataset_split == "train",
      )
      if dataset_split == "train":
          dataset = dataset.repeat()
          dataset = dataset.shuffle(1000)
  
      def shift_and_append_eos(t):
          # tfds encoder does not reserve an EOS token, so we need to shift
          # in order to do so.  We also append EOS=1.
          return tf.concat([t + 1, [1]], 0)
  
      def feature_map(inputs, targets):
          if text2self:
              return {"targets": shift_and_append_eos(targets)}
          else:
              return {
                  "inputs": shift_and_append_eos(inputs),
                  "targets": shift_and_append_eos(targets),
              }
  
      dataset = dataset.map(
          feature_map, num_parallel_calls=tf.data.experimental.AUTOTUNE
      )
      return pack_or_pad(dataset, sequence_length)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import gin
  import tensorflow.compat.v1
  import tensorflow_datasets
label_desc: Use image node_id 4 for calling a global function with example usage: pretokenized_tfds_dataset(dataset_name, text2tfds_data_dir, dataset_split, batch_size, sequence_length, vocabulary) and returns: pack_or_pad, tf, dict, dict