code: def testVocabularyPreSort(self):
      input_data = [
          dict(x=b"foo"),
          dict(x=b"hello"),
          dict(x=b"aaaaa"),
          dict(x=b"goodbye"),
          dict(x=b"bar"),
          dict(x=b"hello"),
          dict(x=b"goodbye"),
          dict(x=b"hello"),
          dict(x=b"hello"),
          dict(x=b"goodbye"),
          dict(x=b"aaaaa"),
      ]
      input_metadata = tft.DatasetMetadata.from_feature_spec(
          {"x": tf.io.FixedLenFeature([], tf.string)}
      )
      expected_vocab_file_contents = [
          (b"hello", 4),
          (b"goodbye", 3),
          (b"aaaaa", 2),
          (b"foo", 1),
          (b"bar", 1),
      ]
  
      def preprocessing_fn(inputs):
          tft.vocabulary(
              inputs["x"],
              vocab_filename="my_vocab",
              file_format=self._VocabFormat(),
              store_frequency=True,
          )
          return inputs
  
      with tf.compat.v1.test.mock.patch.object(
          analyzer_impls, "_PRESORT_BATCH_SIZE", 2
      ):
          self.assertAnalyzeAndTransformResults(
              input_data,
              input_metadata,
              preprocessing_fn,
              input_data,
              input_metadata,
              expected_vocab_file_contents={
                  "my_vocab": expected_vocab_file_contents
              },
          )
  
imports: import os
  import apache_beam
  import tensorflow
  import tensorflow_transform
  from tensorflow_transform.beam import analyzer_impls
  from tensorflow_transform.beam import impl
  from tensorflow_transform.beam.tft_beam_io import transform_fn_io
  from tensorflow_transform.beam import tft_unit
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 15 for calling the VocabularyIntegrationTest obj's underlying member method code with example usage: obj.testVocabularyPreSort() and returns: inputs