code: def testFilterFusion(self, function, predicates):
      dataset = (
          dataset_ops.Dataset.range(5)
          .apply(
              testing.assert_next(["Map", "Filter", "MemoryCacheImpl"])
          )
          .map(function)
      )
      for predicate in predicates:
          dataset = dataset.filter(predicate)
  
      dataset = dataset.cache()
      options = options_lib.Options()
      options.experimental_optimization.apply_default_optimizations = (
          False
      )
      options.experimental_optimization.filter_fusion = True
      dataset = dataset.with_options(options)
      expected_output = []
      for x in range(5):
          r = function(x)
          filtered = False
          for predicate in predicates:
              if isinstance(r, tuple):
                  b = predicate(*r)  # Pass tuple as multiple arguments.
              else:
                  b = predicate(r)
              if not self.evaluate(b):
                  filtered = True
                  break
  
          if not filtered:
              expected_output.append(r)
      self.assertDatasetProduces(
          dataset, expected_output=expected_output
      )
  
file_path: tensorflow/tensorflow/python/data/experimental/kernel_tests/optimization/filter_fusion_test.py
imports: import functools
  from absl.testing import parameterized
  from tensorflow.python.data.experimental.ops import testing
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the FilterFusionTest obj's underlying member method code with example usage: obj.testFilterFusion(function, predicates) without return types