class_docstr: Base abstract class for all zero-copy map fusion rules.
  
  A zero-copy map fusion rule is a rule that optimizes the transform_fn chain of
  a fused MapOperator. The optimization is usually done by removing unnecessary
  data conversions.
  
  This base abstract class defines the common util functions. And subclasses
  should implement the `_optimize` method for the concrete optimization
  strategy.
docstr: Traverse the DAG and apply the optimization to each MapOperator.
docstr_tok: ["Traverse","the","DAG","and","apply","the","optimization","to","each","MapOperator","."]
code: def _traverse(self, op):
      """Traverse the DAG and apply the optimization to each MapOperator."""
      if isinstance(op, MapOperator):
          map_transformer = op.get_map_transformer()
          transform_fns = map_transformer.get_transform_fns()
          new_transform_fns = self._optimize(transform_fns)
          # Physical operators won't be shared,
          # so it's safe to modify the transform_fns in place.
          map_transformer.set_transform_fns(new_transform_fns)
  
      for input_op in op.input_dependencies:
          self._traverse(input_op)
  
file_path: ray/python/ray/data/_internal/logical/rules/zero_copy_map_fusion.py
imports: from abc import abstractmethod
  from typing import List
  from ray.data._internal.execution.operators.map_operator import MapOperator
  from ray.data._internal.execution.operators.map_transformer import BuildOutputBlocksMapTransformFn, MapTransformFn, MapTransformFnDataType
  from ray.data._internal.logical.interfaces.optimizer import Rule
  from ray.data._internal.logical.interfaces.physical_plan import PhysicalPlan
label_desc: Use image node_id 2 for calling the ZeroCopyMapFusionRule obj's underlying member method code with example usage: obj._traverse(op) without return types