def _vocabulary_analyzer_nodes(
    analyzer_inputs: Collection[tf.Tensor],
    input_dtype: tf.dtypes.DType,
    vocab_ordering_type: int,
    vocab_filename: str,
    top_k: Optional[int] = None,
    frequency_threshold: int = 0,
    informativeness_threshold: float = float('-inf'),
    use_adjusted_mutual_info: bool = False,
    min_diff_from_avg: Optional[int] = None,
    fingerprint_shuffle: bool = False,
    store_frequency: bool = False,
    key_fn: Optional[Callable[[Any], Any]] = None,
    coverage_top_k: Optional[int] = None,
    coverage_frequency_threshold: float = 0.0,
    coverage_informativeness_threshold: float = float('-inf'),
    file_format: common_types.VocabularyFileFormatType = DEFAULT_VOCABULARY_FILE_FORMAT,
    vocabulary_key: Optional[str] = None,
    reserved_tokens: Optional[Union[Sequence[str], tf.Tensor]] = None,
) -> common_types.TemporaryAnalyzerOutputType:
  """Internal helper for analyzing vocab. See `vocabulary` doc string."""

  input_values_node = analyzer_nodes.get_input_tensors_value_nodes(
      analyzer_inputs)

  accumulate_output_value_node = nodes.apply_operation(
      analyzer_nodes.VocabularyAccumulate,
      input_values_node,
      vocab_ordering_type=vocab_ordering_type,
      input_dtype=input_dtype)

  merge_output_value_node = nodes.apply_operation(
      analyzer_nodes.VocabularyMerge,
      accumulate_output_value_node,
      use_adjusted_mutual_info=use_adjusted_mutual_info,
      min_diff_from_avg=min_diff_from_avg,
      vocab_ordering_type=vocab_ordering_type)

  filtered_value_node = nodes.apply_operation(
      analyzer_nodes.VocabularyPrune,
      merge_output_value_node,
      coverage_top_k=coverage_top_k,
      coverage_frequency_threshold=coverage_frequency_threshold,
      coverage_informativeness_threshold=coverage_informativeness_threshold,
      key_fn=key_fn,
      top_k=top_k,
      frequency_threshold=frequency_threshold,
      informativeness_threshold=informativeness_threshold,
      input_dtype=input_dtype)

  reserved_tokens_size = 0
  extra_apply_order_and_write_op_args = []
  if reserved_tokens is not None:
    reserved_tokens_size = tf_utils.register_vocabulary_reserved_tokens(
        vocab_filename, reserved_tokens
    )
    extra_apply_order_and_write_op_args.append(
        nodes.apply_operation(
            analyzer_nodes.ExtractVocabularyReservedTokens, name=vocab_filename
        )
    )

  vocab_filename_node = nodes.apply_operation(
      analyzer_nodes.VocabularyOrderAndWrite,
      filtered_value_node,
      *extra_apply_order_and_write_op_args,
      vocab_filename=vocab_filename,
      store_frequency=store_frequency,
      fingerprint_shuffle=fingerprint_shuffle,
      input_dtype=input_dtype,
      file_format=file_format,
      # LINT.IfChange(input_is_sorted)
      input_is_sorted=(
          top_k is not None and key_fn is None and not fingerprint_shuffle
      ),
      # LINT.ThenChange(beam/analyzer_impls.py:top_k_impl)
  )

  scope = tf.compat.v1.get_default_graph().get_name_scope()
  unfiltered_vocab_size_node = nodes.apply_operation(
      analyzer_nodes.VocabularyCount,
      merge_output_value_node,
      label=f'VocabularyCountUnfiltered[{scope}]')
  unfiltered_vocab_size = analyzer_nodes.bind_future_as_tensor(
      unfiltered_vocab_size_node,
      analyzer_nodes.TensorInfo(tf.int64, [], None),
      name=f'{vocab_filename}_unpruned_vocab_size')
  filtered_vocab_size_node = nodes.apply_operation(
      analyzer_nodes.VocabularyCount,
      filtered_value_node,
      label=f'VocabularyCountFiltered[{scope}]')
  filtered_vocab_size = analyzer_nodes.bind_future_as_tensor(
      filtered_vocab_size_node,
      analyzer_nodes.TensorInfo(tf.int64, [], None),
      name=f'{vocab_filename}_pruned_vocab_size')

  unfiltered_vocab_size += reserved_tokens_size
  filtered_vocab_size += reserved_tokens_size
  _maybe_annotate_vocab_metadata(vocab_filename, unfiltered_vocab_size,
                                 filtered_vocab_size)

  register_vocab(
      vocab_filename,
      vocabulary_size=filtered_vocab_size,
      vocabulary_key=vocabulary_key,
      file_format=file_format)
  return analyzer_nodes.wrap_as_tensor(vocab_filename_node)
Internal helper for analyzing vocab. See `vocabulary` doc string.
tensorflow_transform/analyzers.py