<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cumprod(vari, axis=None):
 """ Perform the cumulative product of a shapeable quantity over a given axis. Args: vari (chaospy.poly.base.Poly, numpy.ndarray):
 Input data. axis (int):
 Axis over which the sum is taken. By default ``axis`` is None, and all elements are summed. Returns: (chaospy.poly.base.Poly):
 An array shaped as ``vari`` but with the specified axis removed. Examples: [1, q0, q0^2, q0^3] [1, q0, q0^3, q0^6] """

    if isinstance(vari, Poly):
        if np.prod(vari.shape) == 1:
            return vari.copy()
        if axis is None:
            vari = chaospy.poly.shaping.flatten(vari)
            axis = 0

        vari = chaospy.poly.shaping.rollaxis(vari, axis)
        out = [vari[0]]

        for poly in vari[1:]:
            out.append(out[-1]*poly)
        return Poly(out, vari.dim, vari.shape, vari.dtype)

    return np.cumprod(vari, axis)