code: def packed_parallel_tsv_dataset(
      dataset=gin.REQUIRED,
      dataset_split=gin.REQUIRED,
      batch_size=None,
      sequence_length=gin.REQUIRED,
      vocabulary=gin.REQUIRED,
      append_eos=True,
      eos_id=1,
      max_encoded_len=0,
  ):
      """Reads parallel tab-separated text file. One example per line."""
      del batch_size
      del dataset_split
  
      def _parse_fn(record):  # pylint: disable=missing-docstring
          tokens = tf.decode_csv(
              record,
              record_defaults=[""] * 2,
              field_delim="\t",
              use_quote_delim=False,
          )
          return {"inputs": tokens[0], "targets": tokens[1]}
  
      def _encode_fn(features):  # pylint: disable=missing-docstring
          inputs_vocabulary = (
              vocabulary[0]
              if isinstance(vocabulary, tuple)
              else vocabulary
          )
          targets_vocabulary = (
              vocabulary[1]
              if isinstance(vocabulary, tuple)
              else vocabulary
          )
          inputs_enc = inputs_vocabulary.encode_tf(features["inputs"])
          targets_enc = targets_vocabulary.encode_tf(
              features["targets"]
          )
          if append_eos:
              inputs_enc = tf.concat(
                  [tf.cast(inputs_enc, tf.int64), [eos_id]], 0
              )
              targets_enc = tf.concat(
                  [tf.cast(targets_enc, tf.int64), [eos_id]], 0
              )
          return {"inputs": inputs_enc, "targets": targets_enc}
  
      dataset = dataset.map(
          _parse_fn, num_parallel_calls=tf.data.experimental.AUTOTUNE
      )
      dataset = dataset.map(
          _encode_fn, num_parallel_calls=tf.data.experimental.AUTOTUNE
      )
  
      def _filter_fn(features):  # pylint: disable=missing-docstring
          return tf.less_equal(
              tf.reduce_max(
                  tf.stack(
                      [tf.size(v) for v in features.values()], axis=0
                  )
              ),
              max_encoded_len,
          )
  
      if max_encoded_len:
          tf.logging.info(
              "Filtering encoded examples longer than %d"
              % max_encoded_len
          )
          dataset = dataset.filter(_filter_fn)
  
      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 8 for calling a global function with example usage: packed_parallel_tsv_dataset(dataset, dataset_split, batch_size, sequence_length, vocabulary, append_eos, eos_id, max_encoded_len) and returns: pack_or_pad, dict, dict, tf