class_docstr: Test that the tensorflow execute function can be differentiated
class_docstr_tok: ["Test","that","the","tensorflow","execute","function","can","be","differentiated"]
docstr: Test that setting the max_diff parameter blocks higher-order
  derivatives
docstr_tok: ["Test","that","setting","the","max_diff","parameter","blocks","higher-order","derivatives"]
code: def test_max_diff(self, tol):
      """Test that setting the max_diff parameter blocks higher-order
      derivatives"""
      dev = DefaultQubit()
      params = tf.Variable([0.543, -0.654])
  
      def cost_fn(x):
          ops = [qml.RX(x[0], 0), qml.RY(x[1], 1), qml.CNOT((0, 1))]
          tape1 = qml.tape.QuantumScript(
              ops, [qml.var(qml.PauliZ(0) @ qml.PauliX(1))]
          )
  
          ops2 = [qml.RX(x[0], 0), qml.RY(x[0], 1), qml.CNOT((0, 1))]
          tape2 = qml.tape.QuantumScript(ops2, [qml.probs(wires=1)])
  
          result = execute(
              [tape1, tape2], dev, gradient_fn=param_shift, max_diff=1
          )
          return result[0] + result[1][0]
  
      with tf.GradientTape() as jac_tape:
          with tf.GradientTape() as grad_tape:
              res = cost_fn(params)
          grad = grad_tape.gradient(res, params)
      hess = jac_tape.gradient(grad, params)
  
      x, y = params
      expected = 0.5 * (3 + tf.cos(x) ** 2 * tf.cos(2 * y))
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
      expected = tf.convert_to_tensor(
          [
              -tf.cos(x) * tf.cos(2 * y) * tf.sin(x),
              -tf.cos(x) ** 2 * tf.sin(2 * y),
          ]
      )
      assert np.allclose(grad, expected, atol=tol, rtol=0)
      assert hess is None
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.devices import DefaultQubit
  from pennylane.gradients import param_shift
  from pennylane import execute
label_desc: Use image node_id 2 for calling the TestHigherOrderDerivatives obj's underlying member method code with example usage: obj.test_max_diff(tol) and returns: unknown