Simple laplacian pyramid paramaterization of an image.

    For more flexibility, use a sum of lowres_tensor()s.

    Args:
      shape: shape of resulting image, [batch, width, height, channels].
      n_levels: number of levels of laplacian pyarmid.
      sd: standard deviation of param initialization.

    Returns:
      tensor with shape from first argument.

def laplacian_pyramid_image(shape, n_levels=4, sd=None):
    """Simple laplacian pyramid paramaterization of an image.

    For more flexibility, use a sum of lowres_tensor()s.

    Args:
      shape: shape of resulting image, [batch, width, height, channels].
      n_levels: number of levels of laplacian pyarmid.
      sd: standard deviation of param initialization.

    Returns:
      tensor with shape from first argument.
    """
    batch_dims = shape[:-3]
    w, h, ch = shape[-3:]
    pyramid = 0
    for n in range(n_levels):
        k = 2 ** n
        pyramid += lowres_tensor(shape, batch_dims + (w // k, h // k, ch), sd=sd)
    return pyramid