def _randomly_sample_from_stabilizer_bases(
    stabilizer_basis: list[cirq.DensePauliString], n_measured_operators: int, n_qubits: int
):
    """Randomly creates Pauli states by including or not the given stabilizer basis.

    Args:
        stabilizer_basis: A list of Pauli strings that is the stabilizer basis
            to sample from.
        n_measured_operators: The total number of Pauli measurements, or None to
            explore each Pauli state once.
        n_qubits: An integer that is the number of qubits.

    Returns:
        A list of Pauli strings that is the Pauli states built.
    """
    dense_pauli_strings = []
    for _ in range(n_measured_operators):
        # Build the Pauli string as a random sample of the basis elements.
        dense_pauli_string = cirq.DensePauliString.eye(n_qubits)
        for stabilizer in stabilizer_basis:
            if np.random.randint(2) == 1:
                dense_pauli_string *= stabilizer
        dense_pauli_strings.append(dense_pauli_string)
    return dense_pauli_strings
Randomly creates Pauli states by including or not the given stabilizer basis.

    Args:
        stabilizer_basis: A list of Pauli strings that is the stabilizer basis
            to sample from.
        n_measured_operators: The total number of Pauli measurements, or None to
            explore each Pauli state once.
        n_qubits: An integer that is the number of qubits.

    Returns:
        A list of Pauli strings that is the Pauli states built.
    
examples/direct_fidelity_estimation.py