def simulate_circuit(
    simulator: cirq.Simulator, circuit: cirq.Circuit, cycle_depths: Sequence[int]
) -> Sequence[np.ndarray]:
    """Simulates the given circuit and returns the state probabilities for each cycle depth.

    Args:
        simulator: A cirq simulator.
        circuit: The circuit to simulate.
        cycle_depths: A sequence of integers representing the depths for which we need the
            state probabilities.

    Returns:
        - The cuircuit_id, same as given in input.
        - The state probabilities for each cycle depth.
    """
    cycle_depths_set = frozenset(cycle_depths)
    result = []
    for moment_i, step_result in enumerate(simulator.simulate_moment_steps(circuit=circuit)):
        # Translate from moment_i to cycle_depth:
        # We know circuit_depth = cycle_depth * 2 + 1, and step_result is the result *after*
        # moment_i, so circuit_depth = moment_i + 1 and moment_i = cycle_depth * 2.
        if moment_i % 2 == 1:
            continue
        cycle_depth = moment_i // 2
        if cycle_depth not in cycle_depths_set:
            continue

        psi = step_result.state_vector()
        pure_probs = value.state_vector_to_probabilities(psi)

        result.append(pure_probs)
    return result
Simulates the given circuit and returns the state probabilities for each cycle depth.

    Args:
        simulator: A cirq simulator.
        circuit: The circuit to simulate.
        cycle_depths: A sequence of integers representing the depths for which we need the
            state probabilities.

    Returns:
        - The cuircuit_id, same as given in input.
        - The state probabilities for each cycle depth.
    
cirq-core/cirq/experiments/benchmarking/parallel_xeb.py