def _choose_optimal_swap(
        cls,
        mm: mapping_manager.MappingManager,
        two_qubit_ops_ints: Sequence[Sequence[QidIntPair]],
        timestep: int,
        lookahead_radius: int,
        sigma: Sequence[tuple[QidIntPair, ...]],
    ) -> tuple[QidIntPair, ...] | None:
        """Optionally returns the swap with minimum cost from a list of n-tuple candidate swaps.

        Computes a cost (as defined by the overridable function `_cost`) for each candidate swap
        in the current timestep. If there does not exist a unique list of swaps with minial cost,
        proceeds to the rank the subset of minimal swaps from the current timestep in the next
        timestep. Iterate this this looking ahead process up to the next `lookahead_radius`
        timesteps. If there still doesn't exist a unique swap with minial cost then returns None.
        """
        for s in range(timestep, min(lookahead_radius + timestep, len(two_qubit_ops_ints))):
            if len(sigma) <= 1:
                break

            costs = {}
            for swaps in sigma:
                costs[swaps] = cls._cost(mm, swaps, two_qubit_ops_ints[s])
            _, min_cost = min(costs.items(), key=lambda x: x[1])
            sigma = [swaps for swaps, cost in costs.items() if cost == min_cost]

        return (
            None
            if len(sigma) > 1 and timestep + lookahead_radius <= len(two_qubit_ops_ints)
            else sigma[0]
        )
Optionally returns the swap with minimum cost from a list of n-tuple candidate swaps.

        Computes a cost (as defined by the overridable function `_cost`) for each candidate swap
        in the current timestep. If there does not exist a unique list of swaps with minial cost,
        proceeds to the rank the subset of minimal swaps from the current timestep in the next
        timestep. Iterate this this looking ahead process up to the next `lookahead_radius`
        timesteps. If there still doesn't exist a unique swap with minial cost then returns None.
        
cirq-core/cirq/transformers/routing/route_circuit_cqc.py