human
Complete the below
def distorted_images(images=None, height=24, width=24):

    ''''Distort images for generating more training data.
    Features
    They are cropped to height * width pixels randomly.
    They are approximately whitened to make the model insensitive to dynamic range.
    Randomly flip the image from left to right.
    Randomly distort the image brightness.
    Randomly distort the image contrast.
    Whiten (Normalize) the images.
    Parameters
    images : 4D Tensor
    The tensor or placeholder of images
    height : int
    The height for random crop.
    width : int
    The width for random crop.
    Returns
    result : tuple of Tensor
    (Tensor for distorted images, Tensor for while loop index)
    Examples
    >>> X_train, y_train, X_test, y_test = tl.files.load_cifar10_dataset(shape=(-1, 32, 32, 3), plotable=False)
    >>> sess = tf.InteractiveSession()
    >>> batch_size = 128
    >>> x = tf.placeholder(tf.float32, shape=[batch_size, 32, 32, 3])
    >>> distorted_images_op = tl.preprocess.distorted_images(images=x, height=24, width=24)
    >>> sess.run(tf.initialize_all_variables())
    >>> feed_dict={x: X_train[0:batch_size,:,:,:]}
    >>> distorted_images, idx = sess.run(distorted_images_op, feed_dict=feed_dict)
    >>> tl.visualize.images2d(X_train[0:9,:,:,:], second=2, saveable=False, name=\'cifar10\', dtype=np.uint8, fig_idx=20212)
    >>> tl.visualize.images2d(distorted_images[1:10,:,:,:], second=10, saveable=False, name=\'distorted_images\', dtype=None, fig_idx=23012)
    Notes
    - The first image in \'distorted_images\' should be removed.
    References
    - `tensorflow.models.image.cifar10.cifar10_input <https://github.com/tensorflow/tensorflow/blob/r0.9/tensorflow/models/image/cifar10/cifar10_input.py>`_'
    '''
 Write me a the Python code you requested?
assistant
#Here is the Python code you requested.
    print 'This    function    is    deprecated,    please    use    tf.map_fn    instead,    e.g:\n                                                            t_image    =    tf.map_fn(lambda    img:    tf.image.random_brightness(img,    max_delta=32.    /    255.),    t_image)\n                                                    t_image    =    tf.map_fn(lambda    img:    tf.image.random_contrast(img,    lower=0.5,    upper=1.5),    t_image)\n                                                    t_image    =    tf.map_fn(lambda    img:    tf.image.random_saturation(img,    lower=0.5,    upper=1.5),    t_image)\n                                                    t_image    =    tf.map_fn(lambda    img:    tf.image.random_hue(img,    max_delta=0.032),    t_image)'
    exit()
    try:
        batch_size = int(images._shape[0])
    except:
        raise Exception('unknow    batch_size    of    images')
    distorted_x = tf.Variable(tf.constant(0.1, shape=[1, height, width, 3]))
    i = tf.Variable(tf.constant(0))
    c = (lambda distorted_x, i: tf.less(i, batch_size))
    def body(distorted_x, i):
        image = tf.random_crop(tf.gather(images, i), [height, width, 3])
        image = tf.image.random_flip_left_right(image)
        image = tf.image.random_brightness(image, max_delta=63)
        image = tf.image.random_contrast(image, lower=0.2, upper=1.8)
        image = tf.image.per_image_whitening(image)
        image = tf.expand_dims(image, 0)
        return (tf.concat(0, [distorted_x, image]), tf.add(i, 1))
    result = tf.while_loop(cond=c, body=body, loop_vars=(distorted_x, i), parallel_iterations=16)
    return result