code: def test_behaviour():
      """Test that the function behaves as expected."""
  
      dev = qml.device("default.qubit", wires=2)
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.RY(0.3, wires=0)
          qml.RX(0.5, wires=1)
          qml.CNOT(wires=[0, 1])
          qml.expval(
              qml.Hamiltonian(
                  [-1.5, 2.0], [qml.PauliZ(0), qml.PauliZ(1)]
              )
          )
  
      tape = qml.tape.QuantumScript.from_queue(q)
      tape.trainable_params = {2, 3}
      tapes, processing_fn = hamiltonian_grad(tape, idx=0)
      res1 = processing_fn(dev.execute(tapes))
  
      tapes, processing_fn = hamiltonian_grad(tape, idx=1)
      res2 = processing_fn(dev.execute(tapes))
  
      with qml.queuing.AnnotatedQueue() as q1:
          qml.RY(0.3, wires=0)
          qml.RX(0.5, wires=1)
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliZ(0))
  
      tape1 = qml.tape.QuantumScript.from_queue(q1)
      with qml.queuing.AnnotatedQueue() as q2:
          qml.RY(0.3, wires=0)
          qml.RX(0.5, wires=1)
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliZ(1))
  
      tape2 = qml.tape.QuantumScript.from_queue(q2)
      res_expected1 = qml.math.squeeze(dev.execute(tape1))
      res_expected2 = qml.math.squeeze(dev.execute(tape2))
  
      assert res_expected1 == res1
      assert res_expected2 == res2
  
label_desc: Use image node_id 1 for calling a global function with example usage: test_behaviour() without return types