code: def flatten(vari):
      
      if isinstance(vari, Poly):
          shape = int(numpy.prod(vari.shape))
          return reshape(vari, (shape,))
  
      return numpy.array(vari).flatten()
docs: 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:
          >>> P = chaospy.reshape(chaospy.prange(4), (2,2))
          >>> print(P)
          [[1, q0], [q0^2, q0^3]]
          >>> print(chaospy.flatten(P))
          [1, q0, q0^2, q0^3]