code: def testMapFusion(self, functions, num_parallel_calls, deterministic):
      dataset = dataset_ops.Dataset.range(5)
      if num_parallel_calls is None:
          dataset = dataset.apply(
              testing.assert_next(["Map", "MemoryCacheImpl"])
          )
      elif num_parallel_calls in [dataset_ops.AUTOTUNE]:
          # TODO(b/148614504): Support fusion of parallel maps with
          # non-AUTOTUNE value.
          dataset = dataset.apply(
              testing.assert_next(["ParallelMap", "MemoryCacheImpl"])
          )
      else:
          dataset = dataset.apply(
              testing.assert_next(["ParallelMap", "ParallelMap"])
          )
  
      for function in functions:
          dataset = dataset.map(
              function,
              num_parallel_calls=num_parallel_calls,
              deterministic=deterministic,
          )
  
      dataset = dataset.cache()
      options = options_lib.Options()
      options.experimental_optimization.apply_default_optimizations = (
          False
      )
      options.experimental_optimization.map_fusion = True
      dataset = dataset.with_options(options)
      expected_output = []
      for x in range(5):
          r = x
          for function in functions:
              if isinstance(r, tuple):
                  r = function(*r)  # Pass tuple as multiple arguments.
              else:
                  r = function(r)
          expected_output.append(r)
  
      nondeterministic_ordering = (
          num_parallel_calls is not None
          and deterministic
          is False  # pylint: disable=g-bool-id-comparison
      )
      self.assertDatasetProduces(
          dataset,
          expected_output=expected_output,
          assert_items_equal=nondeterministic_ordering,
      )
  
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.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import check_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the MapFusionTest obj's underlying member method code with example usage: obj.testMapFusion(functions, num_parallel_calls, deterministic) without return types