def __init__(
        self,
        sampler: cirq.Sampler,
        repetitions: int,
        combinations_by_layer: list[CircuitLibraryCombination],
    ):
        """This closure will execute a list of `tasks` with one call to
        `run_batch` on the provided sampler for a given number of repetitions.

        It also keeps a record of the circuit library combinations in order to
        back out which qubit pairs correspond to each pair index. We tag
        our return value with this so it is in the resultant DataFrame, which
        is very convenient for dealing with the results (but not strictly
        necessary, as the information could be extracted from (`layer_i`, `pair_i`).
        """
        self.sampler = sampler
        self.repetitions = repetitions
        self.combinations_by_layer = combinations_by_layer
This closure will execute a list of `tasks` with one call to
        `run_batch` on the provided sampler for a given number of repetitions.

        It also keeps a record of the circuit library combinations in order to
        back out which qubit pairs correspond to each pair index. We tag
        our return value with this so it is in the resultant DataFrame, which
        is very convenient for dealing with the results (but not strictly
        necessary, as the information could be extracted from (`layer_i`, `pair_i`).
        
cirq-core/cirq/experiments/xeb_sampling.py