code: def _filter_input(
      input_tensor,
      vocab_freq_table,
      vocab_min_count,
      vocab_subsampling,
      corpus_size,
      seed,
  ):
      input_tensor = tf.convert_to_tensor(input_tensor)
      """Filters input tensor based on vocab freq, threshold, and subsampling."""
      if vocab_freq_table is None:
          return input_tensor
  
      if not isinstance(vocab_freq_table, tf.lookup.StaticHashTable):
          raise ValueError(
              "vocab_freq_table must be a subclass of "
              "InitializableLookupTableBase (such as HashTable) instead of type "
              "{}.".format(type(vocab_freq_table))
          )
  
      with tf.name_scope("filter_vocab"):
          freq = vocab_freq_table.lookup(input_tensor)
          # Filters out elements in input_tensor that are not found in
          # vocab_freq_table (table returns a default value of -1 specified above when
          # an element is not found).
          mask = tf.math.not_equal(freq, vocab_freq_table.default_value)
  
          # Filters out elements whose vocab frequencies are less than the threshold.
          if vocab_min_count is not None:
              cast_threshold = tf.cast(vocab_min_count, freq.dtype)
              mask = tf.math.logical_and(
                  mask, tf.math.greater_equal(freq, cast_threshold)
              )
  
          input_tensor = tf.boolean_mask(input_tensor, mask)
          freq = tf.boolean_mask(freq, mask)
  
      if not vocab_subsampling:
          return input_tensor
  
      if vocab_subsampling < 0 or vocab_subsampling > 1:
          raise ValueError(
              "Invalid vocab_subsampling={} - it should be within range [0, 1].".format(
                  vocab_subsampling
              )
          )
  
      # Subsamples the input tokens based on vocabulary frequency and
      # vocab_subsampling threshold (ie randomly discard commonly appearing
      # tokens).
      with tf.name_scope("subsample_vocab"):
          corpus_size = tf.cast(corpus_size, tf.dtypes.float64)
          freq = tf.cast(freq, tf.dtypes.float64)
          vocab_subsampling = tf.cast(
              vocab_subsampling, tf.dtypes.float64
          )
  
          # From tensorflow_models/tutorials/embedding/word2vec_kernels.cc, which is
          # suppose to correlate with Eq. 5 in http://arxiv.org/abs/1310.4546.
          keep_prob = (
              tf.math.sqrt(freq / (vocab_subsampling * corpus_size))
              + 1.0
          ) * (vocab_subsampling * corpus_size / freq)
          random_prob = tf.random.uniform(
              tf.shape(freq),
              minval=0,
              maxval=1,
              dtype=tf.dtypes.float64,
              seed=seed,
          )
  
          mask = tf.math.less_equal(random_prob, keep_prob)
          return tf.boolean_mask(input_tensor, mask)
  
file_path: addons/tensorflow_addons/text/skip_gram_ops.py
imports: import csv
  import tensorflow
  from tensorflow_addons.utils.resource_loader import LazySO
  from tensorflow_addons.utils.types import AcceptableDTypes, FloatTensorLike, TensorLike
  from typing import Optional
label_desc: Use image node_id 3 for calling a global function with example usage: _filter_input(input_tensor, vocab_freq_table, vocab_min_count, vocab_subsampling, corpus_size, seed) and returns: input_tensor, input_tensor, tf