code: def _get_approximate_vocabulary_analyzer_inputs(
      x: common_types.TensorType,
      file_format: common_types.VocabularyFileFormatType,
      weights: Optional[common_types.TensorType],
  ) -> Tuple[common_types.TensorType, common_types.TensorType]:
      """Helper for constructing approximate vocabulary inputs from tensors.
  
      Args:
        x: `Tensor`, `SparseTensor`, or `RaggedTensor` to compute vocabulary over.
        file_format: The format of the resulting vocabulary file.
          'tfrecord_gzip' requires tensorflow>=2.4.
        weights: Optional `Tensor` of weights.
  
      Returns:
        A list of batch-reduced `Tensor`s to feed to vocabulary analysis.
      """
      filter_regex = analyzers.get_vocab_newline_characters_regex(
          x.dtype, file_format
      )
      reduced_batch = tf_utils.reduce_batch_weighted_counts(
          x, weights=weights, force=True, filter_regex=filter_regex
      )
      assert reduced_batch.summed_positive_per_x_and_y is None
      if weights is None:
          assert reduced_batch.summed_weights_per_x is None
          return (reduced_batch.unique_x, reduced_batch.counts_per_x)
      else:
          return (
              reduced_batch.unique_x,
              reduced_batch.summed_weights_per_x,
          )
  
imports: from typing import Any, Collection, List, Optional, Tuple, Union, Iterable, Sequence
  import numpy
  import pyarrow
  import tensorflow
  from tensorflow_transform import analyzer_nodes
  from tensorflow_transform import analyzers
  from tensorflow_transform import common
  from tensorflow_transform import common_types
  from tensorflow_transform import nodes
  from tensorflow_transform import tf_utils
  from tfx_bsl import sketches
  from tfx_bsl.types import tfx_namedtuple
  from typing_extensions import Protocol
label_desc: Use image node_id 6 for calling a global function with example usage: _get_approximate_vocabulary_analyzer_inputs(x, file_format, weights) and returns: reduced_batch,  reduced_batch, reduced_batch,  reduced_batch