class_docstr: Singleton global entry point for managing active recording contexts.
  
  This class consists purely of class methods. It both maintains a list of
  recording queues and allows communication with the currently active object.
  
  Queueable objects, like :class:`~.operation.Operator` and :class:`~.measurements.MeasurementProcess`, should
  use ``QueuingManager`` as an entry point for accessing the active queue.
  
  See also: :class:`~.AnnotatedQueue`, :class:`~.tape.QuantumTape`, :meth:`~.operation.Operator.queue`.
  
  Recording queues, such as :class:`~.AnnotatedQueue`, must define the following methods:
  
  * ``append``: define an action to perform when an object append
    request is made.
  
  * ``remove``: define an action to perform when an object removal request is made.
  
  * ``get_info``: retrieve the object's metadata
  
  * ``update_info``: Update an object's metadata if it is already queued.
  
  To start and end recording, the recording queue can use the :meth:`add_active_queue` and
  :meth:`remove_active_queue` methods.
docstr: A context manager and decorator to ensure that contained logic is non-recordable
  or non-queueable within a QNode or quantum tape context.
  
  **Example:**
  
  Consider the function:
  
  >>> def list_of_ops(params, wires):
  ...     return [
  ...         qml.RX(params[0], wires=wires),
  ...         qml.RY(params[1], wires=wires),
  ...         qml.RZ(params[2], wires=wires)
  ...     ]
  
  If executed in a recording context, the operations constructed in the function will be queued:
  
  >>> dev = qml.device("default.qubit", wires=2)
  >>> @qml.qnode(dev)
  ... def circuit(params):
  ...     ops = list_of_ops(params, wires=0)
  ...     qml.apply(ops[-1])  # apply the last operation from the list again
  ...     return qml.expval(qml.PauliZ(0))
  >>> print(qml.draw(circuit)([1, 2, 3]))
  0: ──RX(1.00)──RY(2.00)──RZ(3.00)──RZ(3.00)─┤  <Z>
  
  Using the ``stop_recording`` context manager, all logic contained inside is not queued or recorded.
  
  >>> @qml.qnode(dev)
  ... def circuit(params):
  ...     with qml.QueuingManager.stop_recording():
  ...         ops = list_of_ops(params, wires=0)
  ...     qml.apply(ops[-1])
  ...     return qml.expval(qml.PauliZ(0))
  >>> print(qml.draw(circuit)([1, 2, 3]))
  0: ──RZ(3.00)─┤  <Z>
  
  The context manager can also be used as a decorator on a function:
  
  >>> @qml.QueuingManager.stop_recording()
  ... def list_of_ops(params, wires):
  ...     return [
  ...         qml.RX(params[0], wires=wires),
  ...         qml.RY(params[1], wires=wires),
  ...         qml.RZ(params[2], wires=wires)
  ...     ]
  >>> @qml.qnode(dev)
  ... def circuit(params):
  ...     ops = list_of_ops(params, wires=0)
  ...     qml.apply(ops[-1])
  ...     return qml.expval(qml.PauliZ(0))
  >>> print(qml.draw(circuit)([1, 2, 3]))
  0: ──RZ(3.00)─┤  <Z>
docstr_tok: ["A","context","manager","and","decorator","to","ensure","that","contained","logic","is","non-recordable","or","non-queueable","within","a","QNode","or","quantum","tape","context",".","*","*","Example",":","*","*","Consider","the","function",":",">",">",">","def","list_of_ops","(","params",",","wires",")",":","...","return","[","...","qml.RX","(","params","[","0","]",",","wires=wires",")",",","...","qml.RY","(","params","[","1","]",",","wires=wires",")",",","...","qml.RZ","(","params","[","2","]",",","wires=wires",")","...","]","If","executed","in","a","recording","context",",","the","operations","constructed","in","the","function","will","be","queued",":",">",">",">","dev","=","qml.device","(","``","default.qubit","''",",","wires=2",")",">",">",">","@","qml.qnode","(","dev",")","...","def","circuit","(","params",")",":","...","ops","=","list_of_ops","(","params",",","wires=0",")","...","qml.apply","(","ops","[","-1","]",")","#","apply","the","last","operation","from","the","list","again","...","return","qml.expval","(","qml.PauliZ","(","0",")",")",">",">",">","print","(","qml.draw","(","circuit",")","(","[","1",",","2",",","3","]",")",")","0",":","\u2500\u2500RX","(","1.00",")","\u2500\u2500RY","(","2.00",")","\u2500\u2500RZ","(","3.00",")","\u2500\u2500RZ","(","3.00",")","\u2500\u2524","<","Z",">","Using","the","``","stop_recording","``","context","manager",",","all","logic","contained","inside","is","not","queued","or","recorded",".",">",">",">","@","qml.qnode","(","dev",")","...","def","circuit","(","params",")",":","...","with","qml.QueuingManager.stop_recording","(",")",":","...","ops","=","list_of_ops","(","params",",","wires=0",")","...","qml.apply","(","ops","[","-1","]",")","...","return","qml.expval","(","qml.PauliZ","(","0",")",")",">",">",">","print","(","qml.draw","(","circuit",")","(","[","1",",","2",",","3","]",")",")","0",":","\u2500\u2500RZ","(","3.00",")","\u2500\u2524","<","Z",">","The","context","manager","can","also","be","used","as","a","decorator","on","a","function",":",">",">",">","@","qml.QueuingManager.stop_recording","(",")","...","def","list_of_ops","(","params",",","wires",")",":","...","return","[","...","qml.RX","(","params","[","0","]",",","wires=wires",")",",","...","qml.RY","(","params","[","1","]",",","wires=wires",")",",","...","qml.RZ","(","params","[","2","]",",","wires=wires",")","...","]",">",">",">","@","qml.qnode","(","dev",")","...","def","circuit","(","params",")",":","...","ops","=","list_of_ops","(","params",",","wires=0",")","...","qml.apply","(","ops","[","-1","]",")","...","return","qml.expval","(","qml.PauliZ","(","0",")",")",">",">",">","print","(","qml.draw","(","circuit",")","(","[","1",",","2",",","3","]",")",")","0",":","\u2500\u2500RZ","(","3.00",")","\u2500\u2524","<","Z",">"]
code: def stop_recording(cls):
      """A context manager and decorator to ensure that contained logic is non-recordable
      or non-queueable within a QNode or quantum tape context.
  
      **Example:**
  
      Consider the function:
  
      >>> def list_of_ops(params, wires):
      ...     return [
      ...         qml.RX(params[0], wires=wires),
      ...         qml.RY(params[1], wires=wires),
      ...         qml.RZ(params[2], wires=wires)
      ...     ]
  
      If executed in a recording context, the operations constructed in the function will be queued:
  
      >>> dev = qml.device("default.qubit", wires=2)
      >>> @qml.qnode(dev)
      ... def circuit(params):
      ...     ops = list_of_ops(params, wires=0)
      ...     qml.apply(ops[-1])  # apply the last operation from the list again
      ...     return qml.expval(qml.PauliZ(0))
      >>> print(qml.draw(circuit)([1, 2, 3]))
      0: ──RX(1.00)──RY(2.00)──RZ(3.00)──RZ(3.00)─┤  <Z>
  
      Using the ``stop_recording`` context manager, all logic contained inside is not queued or recorded.
  
      >>> @qml.qnode(dev)
      ... def circuit(params):
      ...     with qml.QueuingManager.stop_recording():
      ...         ops = list_of_ops(params, wires=0)
      ...     qml.apply(ops[-1])
      ...     return qml.expval(qml.PauliZ(0))
      >>> print(qml.draw(circuit)([1, 2, 3]))
      0: ──RZ(3.00)─┤  <Z>
  
      The context manager can also be used as a decorator on a function:
  
      >>> @qml.QueuingManager.stop_recording()
      ... def list_of_ops(params, wires):
      ...     return [
      ...         qml.RX(params[0], wires=wires),
      ...         qml.RY(params[1], wires=wires),
      ...         qml.RZ(params[2], wires=wires)
      ...     ]
      >>> @qml.qnode(dev)
      ... def circuit(params):
      ...     ops = list_of_ops(params, wires=0)
      ...     qml.apply(ops[-1])
      ...     return qml.expval(qml.PauliZ(0))
      >>> print(qml.draw(circuit)([1, 2, 3]))
      0: ──RZ(3.00)─┤  <Z>
  
      """
      previously_active_contexts = cls._active_contexts
      cls._active_contexts = []
      try:
          yield
      except Exception as e:
          cls._active_contexts = previously_active_contexts
          raise e
      cls._active_contexts = previously_active_contexts
  
imports: import copy
  from collections import OrderedDict
  from contextlib import contextmanager
  from threading import RLock
  from typing import Optional
label_desc: Use image node_id 5 for calling the QueuingManager obj's underlying member method code with example usage: obj.stop_recording(cls) without return types