<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convolve_stack(data, kernel, rot_kernel=False, method='scipy'):
 r"""Convolve stack of data with stack of kernels This method convolves the input data with a given kernel using FFT and is the default convolution used for all routines Parameters data : np.ndarray Input data array, normally a 2D image kernel : np.ndarray Input kernel array, normally a 2D kernel rot_kernel : bool Option to rotate kernels by 180 degrees method : str {'astropy', 'scipy'}, optional Convolution method (default is 'scipy') Returns ------- np.ndarray convolved data Examples -------- array([[[ 534., 525., 534.], [ 453., 444., 453.], [ 534., 525., 534.]], <BLANKLINE> [[ 2721., 2712., 2721.], [ 2640., 2631., 2640.], [ 2721., 2712., 2721.]]]) array([[[ 474., 483., 474.], [ 555., 564., 555.], [ 474., 483., 474.]], <BLANKLINE> [[ 2661., 2670., 2661.], [ 2742., 2751., 2742.], [ 2661., 2670., 2661.]]]) See Also -------- convolve : The convolution function called by convolve_stack """


    if rot_kernel:
        kernel = rotate_stack(kernel)

    return np.array([convolve(data_i, kernel_i, method=method) for data_i,
                    kernel_i in zip(data, kernel)])