<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def initialize(self, gyro_rate, slices=None, skip_estimation=False):
 """Prepare calibrator for calibration This method does three things: 1. Create slices from the video stream, if not already provided 2. Estimate time offset 3. Estimate rotation between camera and gyroscope Parameters gyro_rate : float Estimated gyroscope sample rate slices : list of Slice, optional Slices to use for optimization skip_estimation : bool Do not estimate initial time offset and rotation. Raises InitializationError If the initialization fails """

        self.params['user']['gyro_rate'] = gyro_rate

        for p in ('gbias_x', 'gbias_y', 'gbias_z'):
            self.params['initialized'][p] = 0.0

        if slices is not None:
            self.slices = slices

        if self.slices is None:
            self.slices = videoslice.Slice.from_stream_randomly(self.video)
            logger.debug("Number of slices: {:d}".format(len(self.slices)))

        if len(self.slices) < 2:
            logger.error("Calibration requires at least 2 video slices to proceed, got %d", len(self.slices))
            raise InitializationError("Calibration requires at least 2 video slices to proceed, got {:d}".format(len(self.slices)))

        if not skip_estimation:
            time_offset = self.find_initial_offset()
            # TODO: Detect when time offset initialization fails, and raise InitializationError

            R = self.find_initial_rotation()
            if R is None:
                raise InitializationError("Failed to calculate initial rotation")