def unpack(pyramid, backend='numpy'):
    """ Unpacks a pyramid give back the constituent parts.

    :param pyramid: The Pyramid of DTCWT transforms you wish to unpack
    :param str backend: A string from 'numpy', 'opencl', or 'tf' indicating
        which attributes you want to unpack from the pyramid.

    :returns: returns a generator which can be unpacked into the Yl, Yh and
        Yscale components of the pyramid. The generator will only return 2
        values if the pyramid was created with the include_scale parameter set
        to false.

    .. note::

        You can still unpack a tf or opencl pyramid as if it were created by a
        numpy. In this case it will return a numpy array, rather than the
        backend specific array type.
    """
    backend = backend.lower()
    if backend == 'numpy':
        yield pyramid.lowpass
        yield pyramid.highpasses
        if pyramid.scales is not None:
            yield pyramid.scales
    elif backend == 'opencl':
        yield pyramid.cl_lowpass
        yield pyramid.cl_highpasses
        if pyramid.cl_scales is not None:
            yield pyramid.cl_scales
    elif backend == 'tf':
        yield pyramid.lowpass_op
        yield pyramid.highpasses_ops
        if pyramid.scales_ops is not None:
            yield pyramid.scales_ops
