<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flatten(vari):
 """ Flatten a shapeable quantity. Args: vari (chaospy.poly.base.Poly, numpy.ndarray):
 Shapeable input quantity. Returns: (chaospy.poly.base.Poly, numpy.ndarray):
 Same type as ``vari`` with `len(Q.shape)==1`. Examples: [[1, q0], [q0^2, q0^3]] [1, q0, q0^2, q0^3] """

    if isinstance(vari, Poly):
        shape = int(numpy.prod(vari.shape))
        return reshape(vari, (shape,))

    return numpy.array(vari).flatten()