code: def ReadAndShuffleData(pcoll, filepatterns):
      """Read a train or test dataset from disk and shuffle it."""
      # NOTE: we pass filepatterns as a tuple instead of two args, as the current
      # version of beam assumes that if the first arg to a ptransfrom_fn is a
      # string, then that string is the label.
      neg_filepattern, pos_filepattern = filepatterns
  
      # Read from each file pattern and create a tuple of the review text and the
      # correct label.
      negative_examples = (
          pcoll
          | "ReadNegativeExamples"
          >> beam.io.ReadFromText(neg_filepattern)
          | "PairWithZero" >> beam.Map(lambda review: (review, 0))
      )
      positive_examples = (
          pcoll
          | "ReadPositiveExamples"
          >> beam.io.ReadFromText(pos_filepattern)
          | "PairWithOne" >> beam.Map(lambda review: (review, 1))
      )
      all_examples = [
          negative_examples,
          positive_examples,
      ] | "Merge" >> beam.Flatten()
  
      # Shuffle the data.  Note that the data does in fact contain duplicate reviews
      # for reasons that are unclear.  This means that NUM_TRAIN_INSTANCES and
      # NUM_TRAIN_INSTANCES are slightly wrong for the preprocessed data.
      # pylint: disable=no-value-for-parameter
      shuffled_examples = (
          all_examples
          | "Distinct" >> beam.Distinct()
          | "Shuffle" >> Shuffle()
      )
  
      # Put the data in the format that can be accepted directly by tf.Transform.
      return shuffled_examples | "MakeInstances" >> beam.Map(
          lambda p: {REVIEW_KEY: p[0], LABEL_KEY: p[1]}
      )
  
file_path: transform/examples/sentiment_example.py
imports: import argparse
  import os
  import pprint
  import tempfile
  import apache_beam
  import tensorflow
  from tensorflow import estimator
  import tensorflow_transform
  import tensorflow_transform.beam
  from tfx_bsl.public import tfxio
label_desc: Use image node_id 2 for calling a global function with example usage: ReadAndShuffleData(pcoll, filepatterns) and returns: unknown