def _cost(
        cls,
        mm: mapping_manager.MappingManager,
        swaps: tuple[QidIntPair, ...],
        two_qubit_ops: Sequence[QidIntPair],
    ) -> Any:
        """Computes the cost function for the given list of swaps over the current timestep ops.

        To use this transformer with a different cost function, create a new subclass that derives
        from `RouteCQC` and override this method.
        """
        for swap in swaps:
            mm.apply_swap(*swap)
        max_length, sum_length = 0, 0
        for lq in two_qubit_ops:
            dist = mm.dist_on_device(*lq)
            max_length = max(max_length, dist)
            sum_length += dist
        for swap in swaps:
            mm.apply_swap(*swap)
        return max_length, sum_length
Computes the cost function for the given list of swaps over the current timestep ops.

        To use this transformer with a different cost function, create a new subclass that derives
        from `RouteCQC` and override this method.
        
cirq-core/cirq/transformers/routing/route_circuit_cqc.py