class_docstr: A template and quantum function inspector,
  allowing easy introspection of operators that have been
  applied without requiring a QNode.
  
  **Example**:
  
  The OperationRecorder is a context manager. Executing templates
  or quantum functions stores applied operators in the
  recorder, which can then be printed.
  
  >>> shape = qml.templates.StronglyEntanglingLayers.shape(n_layers=1, n_wires=2)
  >>> weights = np.random.random(shape)
  >>>
  >>> with OperationRecorder() as rec:
  >>>    qml.templates.StronglyEntanglingLayers(weights, wires=[0, 1])
  
  
  Alternatively, the :attr:`~.OperationRecorder.queue` attribute can be used
  to directly access the applied :class:`~.Operation` and :class:`~.Observable`
  objects.
class_docstr_tok: ["A","template","and","quantum","function","inspector",",","allowing","easy","introspection","of","operators","that","have","been","applied","without","requiring","a","QNode",".","*","*","Example","*","*",":","The","OperationRecorder","is","a","context","manager",".","Executing","templates","or","quantum","functions","stores","applied","operators","in","the","recorder",",","which","can","then","be","printed",".",">",">",">","shape","=","qml.templates.StronglyEntanglingLayers.shape","(","n_layers=1",",","n_wires=2",")",">",">",">","weights","=","np.random.random","(","shape",")",">",">",">",">",">",">","with","OperationRecorder","(",")","as","rec",":",">",">",">","qml.templates.StronglyEntanglingLayers","(","weights",",","wires=","[","0",",","1","]",")","Alternatively",",","the",":","attr",":","`","~.OperationRecorder.queue","`","attribute","can","be","used","to","directly","access","the","applied",":","class",":","`","~.Operation","`","and",":","class",":","`","~.Observable","`","objects","."]
code: def __exit__(self, exception_type, exception_value, traceback):
      AnnotatedQueue.__exit__(
          self, exception_type, exception_value, traceback
      )
      # After other optimizations in #2963, #2986 and follow-up work, we should check whether
      # calling `_process_queue` only if there is no `exception_type` saves time. This would
      # be done via the following:
      # if exception_type is None:
      #    self._process_queue()
      self._ops, self._measurements = process_queue(self)
      self._update()
  
      for obj, info in self.items():
          QueuingManager.append(obj, **info)
  
      new_tape = self.expand(
          depth=5,
          stop_at=lambda obj: not isinstance(obj, QuantumScript),
      )
      self.ops = new_tape.operations
      self.obs = new_tape.observables
  
file_path: pennylane/pennylane/tape/operation_recorder.py
imports: from pennylane.queuing import AnnotatedQueue, QueuingManager, process_queue
  from .tape import QuantumScript
label_desc: Use image node_id 3 for calling the OperationRecorder obj's underlying member method code with example usage: obj.__exit__(exception_type, exception_value, traceback) without return types