code: def _apply_vocabulary_internal(
      x: common_types.ConsistentTensorType,
      deferred_vocab_filename_tensor: common_types.TemporaryAnalyzerOutputType,
      default_value: Any,
      num_oov_buckets: int,
      lookup_fn: Optional[
          Callable[
              [common_types.TensorType, tf.Tensor],
              Tuple[tf.Tensor, tf.Tensor],
          ]
      ],
      file_format: common_types.VocabularyFileFormatType,
      store_frequency: bool,
      name: Optional[str],
  ) -> common_types.ConsistentTensorType:
      """See apply_vocabulary doc."""
      with tf.compat.v1.name_scope(name, "apply_vocab"):
          if x.dtype != tf.string and not x.dtype.is_integer:
              raise ValueError(
                  "expected tf.string or tf.int[8|16|32|64] but got %r"
                  % x.dtype
              )
  
          if lookup_fn:
              result, table_size = tf_utils.lookup_table(
                  lookup_fn, deferred_vocab_filename_tensor, x
              )
          else:
              if deferred_vocab_filename_tensor is None or (
                  isinstance(
                      deferred_vocab_filename_tensor, (bytes, str)
                  )
                  and not deferred_vocab_filename_tensor
              ):
                  raise ValueError(
                      "`deferred_vocab_filename_tensor` must not be empty."
                  )
              construct_table = (
                  _make_construct_vocabulary_table_function(
                      x,
                      file_format,
                      num_oov_buckets,
                      default_value,
                      store_frequency,
                  )
              )
              x_values = tf_utils.get_values(x)
              result, table_size = tf_utils.construct_and_lookup_table(
                  construct_table,
                  deferred_vocab_filename_tensor,
                  x_values,
              )
              compose_result_fn = (
                  _make_composite_tensor_wrapper_if_composite(x)
              )
              result = compose_result_fn(result)
  
          # Specify schema overrides which will override the values in the schema
          # with the min and max values, which are deferred as they are only known
          # once the analyzer has run.
          #
          # `table_size` includes the num oov buckets.  The default value is only used
          # if num_oov_buckets <= 0.
          min_value = tf.constant(0, tf.int64)
          max_value = table_size - 1
          if num_oov_buckets <= 0:
              min_value = tf.minimum(min_value, default_value)
              max_value = tf.maximum(max_value, default_value)
          schema_inference.set_tensor_schema_override(
              tf_utils.get_values(result), min_value, max_value
          )
          return result
  
imports: import os
  from typing import Any, Callable, Iterable, Optional, Tuple, Union
  import tensorflow
  from tensorflow_transform import analyzers
  from tensorflow_transform import common
  from tensorflow_transform import common_types
  from tensorflow_transform import gaussianization
  from tensorflow_transform import schema_inference
  from tensorflow_transform import tf_utils
  from tfx_bsl.types import tfx_namedtuple
label_desc: Use image node_id 21 for calling a global function with example usage: _apply_vocabulary_internal(x, deferred_vocab_filename_tensor, default_value, num_oov_buckets, lookup_fn, file_format, store_frequency, name) and returns: result