code: def snapshots(qnode):
      r"""Create a function that retrieves snapshot results from a QNode.
  
      Args:
          qnode (.QNode): the input QNode to be simulated
  
      Returns:
          A function that has the same argument signature as ``qnode`` and returns a dictionary.
          When called, the function will execute the QNode on the registered device and retrieve
          the saved snapshots obtained via the :class:`~.pennylane.Snapshot` operation. Additionally,
          the snapshot dictionary always contains the execution results of the QNode, so the use of
          the tag "execution_results" should be avoided to prevent conflicting key names.
  
      **Example**
  
      .. code-block:: python3
  
          dev = qml.device("default.qubit", wires=2)
  
          @qml.qnode(dev, interface=None)
          def circuit():
              qml.Snapshot(measurement=qml.expval(qml.PauliZ(0))
              qml.Hadamard(wires=0)
              qml.Snapshot("very_important_state")
              qml.CNOT(wires=[0, 1])
              qml.Snapshot()
              return qml.expval(qml.PauliX(0))
  
      >>> qml.snapshots(circuit)()
      {0: 1.0,
      'very_important_state': array([0.70710678+0.j, 0.        +0.j, 0.70710678+0.j, 0.        +0.j]),
      2: array([0.70710678+0.j, 0.        +0.j, 0.        +0.j, 0.70710678+0.j]),
      'execution_results': 0.0}
      """
  
      def get_snapshots(*args, **kwargs):
          old_interface = qnode.interface
          if old_interface == "auto":
              qnode.interface = qml.math.get_interface(
                  *args, *list(kwargs.values())
              )
  
          with _Debugger(qnode.device) as dbg:
              results = qnode(*args, **kwargs)
              # Reset interface
              if old_interface == "auto":
                  qnode.interface = "auto"
          dbg.snapshots["execution_results"] = results
          return dbg.snapshots
  
      return get_snapshots
  
imports: import pennylane
  from pennylane import DeviceError
label_desc: Use image node_id 1 for calling a global function with example usage: snapshots(qnode) and returns: get_snapshots, dbg