class_docstr: A `Dataset` that filters its input according to a predicate function.
class_docstr_tok: ["A","`","Dataset","`","that","filters","its","input","according","to","a","predicate","function","."]
docstr: See `Dataset.filter` for details.
docstr_tok: ["See","`","Dataset.filter","`","for","details","."]
code: def __init__(
      self,
      input_dataset,
      predicate,
      use_legacy_function=False,
      name=None,
  ):
      """See `Dataset.filter` for details."""
      self._input_dataset = input_dataset
      wrapped_func = structured_function.StructuredFunctionWrapper(
          predicate,
          self._transformation_name(),
          dataset=input_dataset,
          use_legacy_function=use_legacy_function,
      )
      if not wrapped_func.output_structure.is_compatible_with(
          tensor_spec.TensorSpec([], dtypes.bool)
      ):
          raise ValueError(
              f"Invalid `predicate`. `predicate` must return a "
              f"`tf.bool` scalar tensor, but its return type is "
              f"{wrapped_func.output_structure}."
          )
      self._predicate = wrapped_func
      self._name = name
      variant_tensor = gen_dataset_ops.filter_dataset(
          input_dataset._variant_tensor,  # pylint: disable=protected-access
          other_arguments=self._predicate.function.captured_inputs,
          predicate=self._predicate.function,
          **self._common_args,
      )
      super().__init__(input_dataset, variant_tensor)
  
file_path: tensorflow/tensorflow/python/data/ops/filter_op.py
imports: from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import structured_function
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.ops import gen_dataset_ops
label_desc: Use image node_id 1 to create a new _FilterDataset object from inherited base classes: dataset_ops with example: obj = _FilterDataset(input_dataset, predicate, use_legacy_function, name)