def _make_regex_filter_fn(
    x: tf.Tensor,
    filter_regex: Optional[str]) -> Callable[[tf.Tensor], tf.Tensor]:
  """Returns a filter function that applies `x`'s mask."""
  if filter_regex is None:
    return lambda values: values
  else:
    if x.dtype != tf.string:
      raise ValueError('Regex filtering is only possible with string input, '
                       f'got {x.dtype}')
    filter_mask = tf.logical_not(tf.strings.regex_full_match(x, filter_regex))
    return lambda values: tf.boolean_mask(values, filter_mask)
Returns a filter function that applies `x`'s mask.
tensorflow_transform/tf_utils.py