class_docstr: Holds a list of enqueue operations for a queue, each to be run in a thread.
  
  Queues are a convenient TensorFlow mechanism to compute tensors
  asynchronously using multiple threads. For example in the canonical 'Input
  Reader' setup one set of threads generates filenames in a queue; a second set
  of threads read records from the files, processes them, and enqueues tensors
  on a second queue; a third set of threads dequeues these input records to
  construct batches and runs them through training operations.
  
  There are several delicate issues when running multiple threads that way:
  closing the queues in sequence as the input is exhausted, correctly catching
  and reporting exceptions, etc.
  
  The `QueueRunner`, combined with the `Coordinator`, helps handle these issues.
  
  @compatibility(TF2)
  QueueRunners are not compatible with eager execution. Instead, please
  use [tf.data](https://www.tensorflow.org/guide/data) to get data into your
  model.
  @end_compatibility
class_docstr_tok: ["Holds","a","list","of","enqueue","operations","for","a","queue",",","each","to","be","run","in","a","thread",".","Queues","are","a","convenient","TensorFlow","mechanism","to","compute","tensors","asynchronously","using","multiple","threads",".","For","example","in","the","canonical","'Input","Reader","'","setup","one","set","of","threads","generates","filenames","in","a","queue",";","a","second","set","of","threads","read","records","from","the","files",",","processes","them",",","and","enqueues","tensors","on","a","second","queue",";","a","third","set","of","threads","dequeues","these","input","records","to","construct","batches","and","runs","them","through","training","operations",".","There","are","several","delicate","issues","when","running","multiple","threads","that","way",":","closing","the","queues","in","sequence","as","the","input","is","exhausted",",","correctly","catching","and","reporting","exceptions",",","etc",".","The","`","QueueRunner","`",",","combined","with","the","`","Coordinator","`",",","helps","handle","these","issues",".","@","compatibility","(","TF2",")","QueueRunners","are","not","compatible","with","eager","execution",".","Instead",",","please","use","[","tf.data","]","(","https",":","\/\/www.tensorflow.org\/guide\/data",")","to","get","data","into","your","model",".","@","end_compatibility"]
docstr: Create a QueueRunner.
  
  On construction the `QueueRunner` adds an op to close the queue.  That op
  will be run if the enqueue ops raise exceptions.
  
  When you later call the `create_threads()` method, the `QueueRunner` will
  create one thread for each op in `enqueue_ops`.  Each thread will run its
  enqueue op in parallel with the other threads.  The enqueue ops do not have
  to all be the same op, but it is expected that they all enqueue tensors in
  `queue`.
  
  Args:
    queue: A `Queue`.
    enqueue_ops: List of enqueue ops to run in threads later.
    close_op: Op to close the queue. Pending enqueue ops are preserved.
    cancel_op: Op to close the queue and cancel pending enqueue ops.
    queue_closed_exception_types: Optional tuple of Exception types that
      indicate that the queue has been closed when raised during an enqueue
      operation.  Defaults to `(tf.errors.OutOfRangeError,)`.  Another common
      case includes `(tf.errors.OutOfRangeError, tf.errors.CancelledError)`,
      when some of the enqueue ops may dequeue from other Queues.
    queue_runner_def: Optional `QueueRunnerDef` protocol buffer. If specified,
      recreates the QueueRunner from its contents. `queue_runner_def` and the
      other arguments are mutually exclusive.
    import_scope: Optional `string`. Name scope to add. Only used when
      initializing from protocol buffer.
  
  Raises:
    ValueError: If both `queue_runner_def` and `queue` are both specified.
    ValueError: If `queue` or `enqueue_ops` are not provided when not
      restoring from `queue_runner_def`.
    RuntimeError: If eager execution is enabled.
docstr_tok: ["Create","a","QueueRunner",".","On","construction","the","`","QueueRunner","`","adds","an","op","to","close","the","queue",".","That","op","will","be","run","if","the","enqueue","ops","raise","exceptions",".","When","you","later","call","the","`","create_threads","(",")","`","method",",","the","`","QueueRunner","`","will","create","one","thread","for","each","op","in","`","enqueue_ops","`",".","Each","thread","will","run","its","enqueue","op","in","parallel","with","the","other","threads",".","The","enqueue","ops","do","not","have","to","all","be","the","same","op",",","but","it","is","expected","that","they","all","enqueue","tensors","in","`","queue","`",".","Args",":","queue",":","A","`","Queue","`",".","enqueue_ops",":","List","of","enqueue","ops","to","run","in","threads","later",".","close_op",":","Op","to","close","the","queue",".","Pending","enqueue","ops","are","preserved",".","cancel_op",":","Op","to","close","the","queue","and","cancel","pending","enqueue","ops",".","queue_closed_exception_types",":","Optional","tuple","of","Exception","types","that","indicate","that","the","queue","has","been","closed","when","raised","during","an","enqueue","operation",".","Defaults","to","`","(","tf.errors.OutOfRangeError",",",")","`",".","Another","common","case","includes","`","(","tf.errors.OutOfRangeError",",","tf.errors.CancelledError",")","`",",","when","some","of","the","enqueue","ops","may","dequeue","from","other","Queues",".","queue_runner_def",":","Optional","`","QueueRunnerDef","`","protocol","buffer",".","If","specified",",","recreates","the","QueueRunner","from","its","contents",".","`","queue_runner_def","`","and","the","other","arguments","are","mutually","exclusive",".","import_scope",":","Optional","`","string","`",".","Name","scope","to","add",".","Only","used","when","initializing","from","protocol","buffer",".","Raises",":","ValueError",":","If","both","`","queue_runner_def","`","and","`","queue","`","are","both","specified",".","ValueError",":","If","`","queue","`","or","`","enqueue_ops","`","are","not","provided","when","not","restoring","from","`","queue_runner_def","`",".","RuntimeError",":","If","eager","execution","is","enabled","."]
code: def __init__(
      self,
      queue=None,
      enqueue_ops=None,
      close_op=None,
      cancel_op=None,
      queue_closed_exception_types=None,
      queue_runner_def=None,
      import_scope=None,
  ):
      """Create a QueueRunner.
  
      On construction the `QueueRunner` adds an op to close the queue.  That op
      will be run if the enqueue ops raise exceptions.
  
      When you later call the `create_threads()` method, the `QueueRunner` will
      create one thread for each op in `enqueue_ops`.  Each thread will run its
      enqueue op in parallel with the other threads.  The enqueue ops do not have
      to all be the same op, but it is expected that they all enqueue tensors in
      `queue`.
  
      Args:
        queue: A `Queue`.
        enqueue_ops: List of enqueue ops to run in threads later.
        close_op: Op to close the queue. Pending enqueue ops are preserved.
        cancel_op: Op to close the queue and cancel pending enqueue ops.
        queue_closed_exception_types: Optional tuple of Exception types that
          indicate that the queue has been closed when raised during an enqueue
          operation.  Defaults to `(tf.errors.OutOfRangeError,)`.  Another common
          case includes `(tf.errors.OutOfRangeError, tf.errors.CancelledError)`,
          when some of the enqueue ops may dequeue from other Queues.
        queue_runner_def: Optional `QueueRunnerDef` protocol buffer. If specified,
          recreates the QueueRunner from its contents. `queue_runner_def` and the
          other arguments are mutually exclusive.
        import_scope: Optional `string`. Name scope to add. Only used when
          initializing from protocol buffer.
  
      Raises:
        ValueError: If both `queue_runner_def` and `queue` are both specified.
        ValueError: If `queue` or `enqueue_ops` are not provided when not
          restoring from `queue_runner_def`.
        RuntimeError: If eager execution is enabled.
      """
      if context.executing_eagerly():
          raise RuntimeError(
              "QueueRunners are not supported when eager execution is enabled. "
              "Instead, please use tf.data to get data into your model."
          )
  
      if queue_runner_def:
          if queue or enqueue_ops:
              raise ValueError(
                  "queue_runner_def and queue are mutually exclusive."
              )
          self._init_from_proto(
              queue_runner_def, import_scope=import_scope
          )
      else:
          self._init_from_args(
              queue=queue,
              enqueue_ops=enqueue_ops,
              close_op=close_op,
              cancel_op=cancel_op,
              queue_closed_exception_types=queue_closed_exception_types,
          )
      # Protect the count of runs to wait for.
      self._lock = threading.Lock()
      # A map from a session object to the number of outstanding queue runner
      # threads for that session.
      self._runs_per_session = weakref.WeakKeyDictionary()
      # List of exceptions raised by the running threads.
      self._exceptions_raised = []
  
imports: import threading
  import weakref
  from tensorflow.core.protobuf import queue_runner_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 to create a new QueueRunner object  with example: obj = QueueRunner(queue, enqueue_ops, close_op, cancel_op, queue_closed_exception_types, queue_runner_def, import_scope)