code: def testVocabularyWithFrequency(self):
      outfile = "vocabulary_with_frequency"
  
      def preprocessing_fn(inputs):
          # Force the analyzer to be executed, and store the frequency file as a
          # side-effect.
          _ = tft.vocabulary(
              inputs["a"],
              vocab_filename=outfile,
              store_frequency=True,
              file_format=self._VocabFormat(),
          )
          _ = tft.vocabulary(
              inputs["a"],
              store_frequency=True,
              file_format=self._VocabFormat(),
          )
          _ = tft.vocabulary(
              inputs["b"],
              store_frequency=True,
              file_format=self._VocabFormat(),
          )
  
          # The following must not produce frequency output, just the vocab words.
          _ = tft.vocabulary(
              inputs["b"], file_format=self._VocabFormat()
          )
          a_int = tft.compute_and_apply_vocabulary(
              inputs["a"], file_format=self._VocabFormat()
          )
  
          # Return input unchanged, this preprocessing_fn is a no-op except for
          # computing uniques.
          return {"a_int": a_int}
  
      input_metadata = tft.DatasetMetadata.from_feature_spec(
          {
              "a": tf.io.FixedLenFeature([], tf.string),
              "b": tf.io.FixedLenFeature([], tf.string),
          }
      )
  
      tft_tmp_dir = os.path.join(self.get_temp_dir(), "temp_dir")
      transform_fn_dir = os.path.join(
          self.get_temp_dir(), "export_transform_fn"
      )
  
      with beam_impl.Context(temp_dir=tft_tmp_dir):
          with self._makeTestPipeline() as pipeline:
              input_data = pipeline | beam.Create(
                  [
                      {"a": "hello", "b": "hi"},
                      {"a": "world", "b": "ho ho"},
                      {"a": "hello", "b": "ho ho"},
                  ]
              )
              transform_fn = (
                  input_data,
                  input_metadata,
              ) | beam_impl.AnalyzeDataset(preprocessing_fn)
              _ = transform_fn | transform_fn_io.WriteTransformFn(
                  transform_fn_dir
              )
  
      self.assertTrue(os.path.isdir(tft_tmp_dir))
  
      tft_output = tft.TFTransformOutput(transform_fn_dir)
      assets_path = os.path.join(
          tft_output.transform_savedmodel_dir,
          tf.saved_model.ASSETS_DIRECTORY,
      )
      self.assertTrue(os.path.isdir(assets_path))
  
      self.assertEqual(
          [b"2 hello", b"1 world"],
          tft_output.vocabulary_by_name(outfile),
      )
  
      self.assertEqual(
          [b"2 hello", b"1 world"],
          tft_output.vocabulary_by_name("vocab_frequency_vocabulary_1"),
      )
  
      self.assertEqual(
          [b"2 ho ho", b"1 hi"],
          tft_output.vocabulary_by_name("vocab_frequency_vocabulary_2"),
      )
  
      self.assertEqual(
          [b"ho ho", b"hi"],
          tft_output.vocabulary_by_name("vocab_vocabulary_3"),
      )
  
      self.assertEqual(
          [b"hello", b"world"],
          tft_output.vocabulary_by_name(
              "vocab_compute_and_apply_vocabulary_vocabulary"
          ),
      )
  
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 12 for calling the VocabularyIntegrationTest obj's underlying member method code with example usage: obj.testVocabularyWithFrequency() and returns: dict