(func)
return wrapper
r"""Decorates a function `func` as producer_func.
    Args:
      func: A function to decorate.
r"""Decorates a function `func` as producer_func.
    Args:
      func: A function to decorate.
r Decorates a function func as producer_func . Args : func : A function to decorate .
def producer_func(func):
    r"""Decorates a function `func` as producer_func.
    Args:
      func: A function to decorate.
    """
    @wraps(func)
    def wrapper(inputs, dtypes, capacity, num_threads):
        r"""
        Args:
            inputs: A inputs queue list to enqueue
            dtypes: Data types of each tensor
            capacity: Queue capacity. Default is 32.
            num_threads: Number of threads. Default is 1.
        """
        # enqueue function
        def enqueue_func(sess, op):
            # read data from source queue
            data = func(sess.run(inputs))
            # create feeder dict
            feed_dict = {}
            for ph, col in zip(placeholders, data):
                feed_dict[ph] = col
            # run session
            sess.run(op, feed_dict=feed_dict)

        # create place holder list
        placeholders = []
        for dtype in dtypes:
            placeholders.append(tf.placeholder(dtype=dtype))

        # create FIFO queue
        queue = tf.FIFOQueue(capacity, dtypes=dtypes)

        # enqueue operation
        enqueue_op = queue.enqueue(placeholders)

        # create queue runner
        runner = _FuncQueueRunner(enqueue_func, queue, [enqueue_op] * num_threads)

        # register to global collection
        tf.train.add_queue_runner(runner)

        # return de-queue operation
        return queue.dequeue()

    return wrapper
def producer_func ( func ) : @ wraps ( func ) def wrapper ( inputs , dtypes , capacity , num_threads ) : r"""
        Args:
            inputs: A inputs queue list to enqueue
            dtypes: Data types of each tensor
            capacity: Queue capacity. Default is 32.
            num_threads: Number of threads. Default is 1.
        """ # enqueue function def enqueue_func ( sess , op ) : # read data from source queue data = func ( sess . run ( inputs ) ) # create feeder dict feed_dict = { } for ph , col in zip ( placeholders , data ) : feed_dict [ ph ] = col # run session sess . run ( op , feed_dict = feed_dict ) # create place holder list placeholders = [ ] for dtype in dtypes : placeholders . append ( tf . placeholder ( dtype = dtype ) ) # create FIFO queue queue = tf . FIFOQueue ( capacity , dtypes = dtypes ) # enqueue operation enqueue_op = queue . enqueue ( placeholders ) # create queue runner runner = _FuncQueueRunner ( enqueue_func , queue , [ enqueue_op ] * num_threads ) # register to global collection tf . train . add_queue_runner ( runner ) # return de-queue operation return queue . dequeue ( ) return wrapper