def state_tomography(
    sampler: cirq.Sampler,
    qubits: Sequence[cirq.Qid],
    circuit: cirq.Circuit,
    repetitions: int = 1000,
    prerotations: Sequence[tuple[float, float]] | None = None,
) -> TomographyResult:
    """This performs n qubit tomography on a cirq circuit

    Follows https://web.physics.ucsb.edu/~martinisgroup/theses/Neeley2010b.pdf
    A.1. State Tomography.
    This is a high level interface for StateTomographyExperiment.

    Args:
        circuit: Circuit to do the tomography on.
        qubits: Qubits to do the tomography on.
        sampler: Sampler to collect the data from.
        repetitions: Number of times to sample each rotation.
        prerotations: Tuples of (phase_exponent, exponent) parameters for gates
            to apply to the qubits before measurement. The actual rotation
            applied will be `cirq.PhasedXPowGate` with the specified values
            of phase_exponent and exponent. If None, we use [(0, 0), (0, 0.5),
            (0.5, 0.5)], which corresponds to rotation gates
            [I, X**0.5, Y**0.5].

    Returns:
        `TomographyResult` which contains the density matrix of the qubits
        determined by tomography.
    """
    exp = StateTomographyExperiment(qubits, prerotations)
    probs = get_state_tomography_data(
        sampler, qubits, circuit, exp.rot_circuit, exp.rot_sweep, repetitions=repetitions
    )
    return exp.fit_density_matrix(probs)
This performs n qubit tomography on a cirq circuit

    Follows https://web.physics.ucsb.edu/~martinisgroup/theses/Neeley2010b.pdf
    A.1. State Tomography.
    This is a high level interface for StateTomographyExperiment.

    Args:
        circuit: Circuit to do the tomography on.
        qubits: Qubits to do the tomography on.
        sampler: Sampler to collect the data from.
        repetitions: Number of times to sample each rotation.
        prerotations: Tuples of (phase_exponent, exponent) parameters for gates
            to apply to the qubits before measurement. The actual rotation
            applied will be `cirq.PhasedXPowGate` with the specified values
            of phase_exponent and exponent. If None, we use [(0, 0), (0, 0.5),
            (0.5, 0.5)], which corresponds to rotation gates
            [I, X**0.5, Y**0.5].

    Returns:
        `TomographyResult` which contains the density matrix of the qubits
        determined by tomography.
    
cirq-core/cirq/experiments/n_qubit_tomography.py