def _build_cr_schedule(
        self,
        backend: Backend,
        flat_top_width: float,
        sigma: float,
    ) -> pulse.ScheduleBlock:
        """GaussianSquared cross resonance pulse.

        Args:
            backend: The target backend.
            flat_top_width: Total length of flat top part of the pulse in units of dt.
            sigma: Sigma of Gaussian edges in units of dt.

        Returns:
            A schedule definition for the cross resonance pulse to measure.
        """
        opt = self.experiment_options

        # Compute valid integer duration
        cr_duration = round_pulse_duration(backend=backend,
                                           duration=flat_top_width +
                                           2 * sigma * opt.risefall)

        with pulse.build(backend, default_alignment="left",
                         name="cr") as cross_resonance:

            # add cross resonance tone
            pulse.play(
                pulse.GaussianSquare(
                    duration=cr_duration,
                    amp=opt.amp,
                    sigma=sigma,
                    width=flat_top_width,
                ),
                pulse.control_channels(*self.physical_qubits)[0],
            )
            # add cancellation tone
            if not np.isclose(opt.amp_t, 0.0):
                pulse.play(
                    pulse.GaussianSquare(
                        duration=cr_duration,
                        amp=opt.amp_t,
                        sigma=sigma,
                        width=flat_top_width,
                    ),
                    pulse.drive_channel(self.physical_qubits[1]),
                )
            else:
                pulse.delay(cr_duration,
                            pulse.drive_channel(self.physical_qubits[1]))

            # place holder for empty drive channels. this is necessary due to known pulse gate bug.
            pulse.delay(cr_duration,
                        pulse.drive_channel(self.physical_qubits[0]))

        return cross_resonance
 def test_control_channel(self):
     """Text context builder control channel."""
     with pulse.build(self.backend):
         self.assertEqual(pulse.control_channels(0, 1)[0],
                          pulse.ControlChannel(0))