def prefetch_input_data(<EOL>reader, file_pattern, is_training, batch_size, values_per_shard, input_queue_capacity_factor=<NUM_LIT:16>,<EOL>num_reader_threads=<NUM_LIT:1>, shard_queue_name="<STR_LIT>", value_queue_name="<STR_LIT>"<EOL>):
data_files = []<EOL>for pattern in file_pattern.split("<STR_LIT:U+002C>"):<EOL><INDENT>data_files.extend(tf.gfile.Glob(pattern))<EOL><DEDENT>if not data_files:<EOL><INDENT>tl.logging.fatal("<STR_LIT>", file_pattern)<EOL><DEDENT>else:<EOL><INDENT>tl.logging.info("<STR_LIT>", len(data_files), file_pattern)<EOL><DEDENT>if is_training:<EOL><INDENT>print("<STR_LIT>")<EOL>filename_queue = tf.train.string_input_producer(data_files, shuffle=True, capacity=<NUM_LIT:16>, name=shard_queue_name)<EOL>min_queue_examples = values_per_shard * input_queue_capacity_factor<EOL>capacity = min_queue_examples + <NUM_LIT:100> * batch_size<EOL>values_queue = tf.RandomShuffleQueue(<EOL>capacity=capacity, min_after_dequeue=min_queue_examples, dtypes=[tf.string],<EOL>name="<STR_LIT>" + value_queue_name<EOL>)<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>")<EOL>filename_queue = tf.train.string_input_producer(data_files, shuffle=False, capacity=<NUM_LIT:1>, name=shard_queue_name)<EOL>capacity = values_per_shard + <NUM_LIT:3> * batch_size<EOL>values_queue = tf.FIFOQueue(capacity=capacity, dtypes=[tf.string], name="<STR_LIT>" + value_queue_name)<EOL><DEDENT>enqueue_ops = []<EOL>for _ in range(num_reader_threads):<EOL><INDENT>_, value = reader.read(filename_queue)<EOL>enqueue_ops.append(values_queue.enqueue([value]))<EOL><DEDENT>tf.train.queue_runner.add_queue_runner(tf.train.queue_runner.QueueRunner(values_queue, enqueue_ops))<EOL>tf.summary.scalar(<EOL>"<STR_LIT>" % (values_queue.name, capacity),<EOL>tf.cast(values_queue.size(), tf.float32) * (<NUM_LIT:1.> / capacity)<EOL>)<EOL>return values_queue<EOL>
Prefetches string values from disk into an input queue.

    In training the capacity of the queue is important because a larger queue
    means better mixing of training examples between shards. The minimum number of
    values kept in the queue is values_per_shard * input_queue_capacity_factor,
    where input_queue_memory factor should be chosen to trade-off better mixing
    with memory usage.

    Args:
        reader: Instance of tf.ReaderBase.
        file_pattern: Comma-separated list of file patterns (e.g.
            /tmp/train_data-?????-of-00100).
        is_training: Boolean; whether prefetching for training or eval.
        batch_size: Model batch size used to determine queue capacity.
        values_per_shard: Approximate number of values per shard.
        input_queue_capacity_factor: Minimum number of values to keep in the queue
        in multiples of values_per_shard. See comments above.
        num_reader_threads: Number of reader threads to fill the queue.
        shard_queue_name: Name for the shards filename queue.
        value_queue_name: Name for the values input queue.

    Returns:
        A Queue containing prefetched string values.