<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reshape(vari, shape):
 """ Reshape the shape of a shapeable quantity. Args: vari (chaospy.poly.base.Poly, numpy.ndarray):
 Shapeable input quantity. shape (tuple):
 The polynomials new shape. Must be compatible with the number of elements in ``vari``. Returns: (chaospy.poly.base.Poly, numpy.ndarray):
 Same type as ``vari``. Examples: [1, q0, q0^2, q0^3, q0^4, q0^5] [[1, q0, q0^2], [q0^3, q0^4, q0^5]] """


    if isinstance(vari, Poly):
        core = vari.A.copy()
        for key in vari.keys:
            core[key] = reshape(core[key], shape)
        out = Poly(core, vari.dim, shape, vari.dtype)
        return out

    return numpy.asarray(vari).reshape(shape)