def __init__(
        self,
        circuit: cirq.AbstractCircuit,
        observable: cirq.PauliSumLike,
        *,
        samples_per_term: int,
        max_samples_per_job: int = 1000000,
    ):
        """Inits PauliSumCollector.

        Args:
            circuit: Produces the state to be tested.
            observable: The pauli product observables to measure. Their sampled
                expectations will be scaled by their coefficients and their
                dictionary weights, and then added up to produce the final
                result.
            samples_per_term: The number of samples to collect for each
                PauliString term in order to estimate its expectation.
            max_samples_per_job: How many samples to request at a time.
        """
        observable = ops.PauliSum.wrap(observable)

        self._circuit = circuit
        self._samples_per_job = max_samples_per_job
        self._pauli_coef_terms = [(p / p.coefficient, p.coefficient) for p in observable if p]

        self._identity_offset = 0
        for p in observable:
            if not p:
                self._identity_offset += p.coefficient

        self._zeros: dict[ops.PauliString, int] = collections.defaultdict(lambda: 0)
        self._ones: dict[ops.PauliString, int] = collections.defaultdict(lambda: 0)
        self._samples_per_term = samples_per_term
        self._total_samples_requested = 0
Inits PauliSumCollector.

        Args:
            circuit: Produces the state to be tested.
            observable: The pauli product observables to measure. Their sampled
                expectations will be scaled by their coefficients and their
                dictionary weights, and then added up to produce the final
                result.
            samples_per_term: The number of samples to collect for each
                PauliString term in order to estimate its expectation.
            max_samples_per_job: How many samples to request at a time.
        
cirq-core/cirq/work/pauli_sum_collector.py