<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def composite_multiscale_entropy(time_series, sample_length, scale, tolerance=None):
 """Calculate the Composite Multiscale Entropy of the given time series. Args: time_series: Time series for analysis sample_length: Number of sequential points of the time series scale: Scale factor Returns: Vector containing Composite Multiscale Entropy Reference: [1] Wu, Shuen-De, et al. "Time series analysis using composite multiscale entropy." Entropy 15.3 (2013):
 1069-1084. """

    cmse = np.zeros((1, scale))

    for i in range(scale):
        for j in range(i):
            tmp = util_granulate_time_series(time_series[j:], i + 1)
            cmse[i] += sample_entropy(tmp, sample_length, tolerance) / (i + 1)
    return cmse