code: def get_random_distorted_bottlenecks(
      sess,
      image_lists,
      how_many,
      category,
      image_dir,
      input_jpeg_tensor,
      distorted_image,
      resized_input_tensor,
      bottleneck_tensor,
  ):
      """Retrieves bottleneck values for training images, after distortions.
  
      If we're training with distortions like crops, scales, or flips, we have to
      recalculate the full model for every image, and so we can't use cached
      bottleneck values. Instead we find random images for the requested category,
      run them through the distortion graph, and then the full graph to get the
      bottleneck results for each.
  
      Args:
        sess: Current TensorFlow Session.
        image_lists: OrderedDict of training images for each label.
        how_many: The integer number of bottleneck values to return.
        category: Name string of which set of images to fetch - training, testing,
        or validation.
        image_dir: Root folder string of the subfolders containing the training
        images.
        input_jpeg_tensor: The input layer we feed the image data to.
        distorted_image: The output node of the distortion graph.
        resized_input_tensor: The input node of the recognition graph.
        bottleneck_tensor: The bottleneck output layer of the CNN graph.
  
      Returns:
        List of bottleneck arrays and their corresponding ground truths.
      """
      class_count = len(image_lists.keys())
      bottlenecks = []
      ground_truths = []
      for unused_i in range(how_many):
          label_index = random.randrange(class_count)
          label_name = list(image_lists.keys())[label_index]
          image_index = random.randrange(MAX_NUM_IMAGES_PER_CLASS + 1)
          image_path = get_image_path(
              image_lists, label_name, image_index, image_dir, category
          )
          if not tf.gfile.Exists(image_path):
              logging.fatal("File does not exist %s", image_path)
          jpeg_data = tf.gfile.GFile(image_path, "rb").read()
          # Note that we materialize the distorted_image_data as a numpy array before
          # sending running inference on the image. This involves 2 memory copies and
          # might be optimized in other implementations.
          distorted_image_data = sess.run(
              distorted_image, {input_jpeg_tensor: jpeg_data}
          )
          bottleneck_values = sess.run(
              bottleneck_tensor,
              {resized_input_tensor: distorted_image_data},
          )
          bottleneck_values = np.squeeze(bottleneck_values)
          bottlenecks.append(bottleneck_values)
          ground_truths.append(label_index)
      return bottlenecks, ground_truths
  
imports: from absl import logging
  import argparse
  import collections
  from datetime import datetime
  import hashlib
  import os.path
  import random
  import re
  import sys
  import numpy
  import tensorflow
  import tensorflow_hub
  from tensorflow.contrib import quantize
label_desc: Use image node_id 11 for calling a global function with example usage: get_random_distorted_bottlenecks(sess, image_lists, how_many, category, image_dir, input_jpeg_tensor, distorted_image, resized_input_tensor, bottleneck_tensor) and returns: bottlenecks,  ground_truths