def __call__(
        self,
        circuit: cirq.AbstractCircuit,
        *,
        context: transformer_api.TransformerContext | None = None,
    ) -> cirq.Circuit:
        """Adds 3 ZPowGates around each calibrated gate to cancel the effect of Z phases.

        Args:
            circuit: Circuit to transform.
            context: Optional transformer context (not used).

        Returns:
            New circuit with the extra ZPowGates.
        """
        new_moments: list[list[cirq.Operation] | cirq.Moment] = []
        for moment in circuit:
            before = []
            after = []
            for op in moment:
                if op.gate != self.target:
                    # not a target.
                    continue
                assert len(op.qubits) == 2
                gate = self.calibration_map.get(op.qubits, None) or self.calibration_map.get(
                    op.qubits[::-1], None
                )
                if gate is None:
                    # no calibration available.
                    continue
                angles = np.array(_z_angles(self.target_as_fsim, gate)) / np.pi
                angles = -angles  # Take the negative to cancel the effect.
                before.append(ops.Z(op.qubits[0]) ** angles[0])
                before.append(ops.Z(op.qubits[1]) ** angles[1])
                after.append(ops.Z(op.qubits[0]) ** angles[2])
            if before:
                new_moments.append(before)
            new_moments.append(moment)
            if after:
                new_moments.append(after)
        return circuits.Circuit.from_moments(*new_moments)
Adds 3 ZPowGates around each calibrated gate to cancel the effect of Z phases.

        Args:
            circuit: Circuit to transform.
            context: Optional transformer context (not used).

        Returns:
            New circuit with the extra ZPowGates.
        
cirq-core/cirq/experiments/z_phase_calibration.py