def __call__(self, task: _Simulate2qXEBTask) -> list[dict[str, Any]]:
        """Helper function for simulating a given (circuit, cycle_depth)."""
        circuit_i = task.circuit_i
        cycle_depths = set(task.cycle_depths)
        circuit = task.circuit
        param_resolver = task.param_resolver

        circuit_max_cycle_depth = (len(circuit) - 1) // 2
        if max(cycle_depths) > circuit_max_cycle_depth:
            raise ValueError("`circuit` was not long enough to compute all `cycle_depths`.")

        records: list[dict[str, Any]] = []
        for moment_i, step_result in enumerate(
            self.simulator.simulate_moment_steps(circuit=circuit, param_resolver=param_resolver)
        ):
            # 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:
                continue

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

            records += [
                {'circuit_i': circuit_i, 'cycle_depth': cycle_depth, 'pure_probs': pure_probs}
            ]

        return records
Helper function for simulating a given (circuit, cycle_depth).
cirq-core/cirq/experiments/xeb_simulation.py