class_docstr: Tests for adjoint_jacobian
class_docstr_tok: ["Tests","for","adjoint_jacobian"]
docstr: Tests that the gradient of a custom operation that only provides a
  matrix and a generator works.
code: def test_custom_op_gradient(self, tol):
      """Tests that the gradient of a custom operation that only provides a
      matrix and a generator works."""
  
      class MyOp(qml.operation.Operation):
          """Custom operation that only defines a generator and a matrix representation."""
  
          num_wires = 1
  
          def generator(self):
              """Generator of MyOp, just a multiple of Pauli X."""
              return qml.PauliX(self.wires) * 1.2
  
          @staticmethod
          def compute_matrix(angle):  # pylint: disable=arguments-differ
              """Matrix representation of MyOp, just the same as a reparametrized RX."""
              return qml.RX.compute_matrix(-2.4 * angle)
  
      params = np.array([np.pi, np.pi / 2, np.pi / 3])
  
      qs = QuantumScript(
          [MyOp(p, w) for p, w in zip(params, [0, 1, 2])],
          [qml.expval(qml.PauliZ(idx)) for idx in range(3)],
      )
      qs_valid, _ = qml.devices.preprocess.decompose(qs, adjoint_ops)
      qs_valid = qs_valid[0]
  
      # circuit jacobians
      jacobian = adjoint_jacobian(qs_valid)
      expected_jacobian = 2.4 * np.diag(np.sin(-2.4 * params))
      assert np.allclose(jacobian, expected_jacobian, atol=tol, rtol=0)
      assert isinstance(jacobian, tuple)
      assert all(isinstance(j, tuple) for j in jacobian)
  
imports: import pytest
  import pennylane
  from pennylane.devices.qubit import adjoint_jacobian, adjoint_jvp, adjoint_vjp
  from pennylane.tape import QuantumScript
  import pennylane.numpy
label_desc: Use image node_id 6 for calling the TestAdjointJacobian obj's underlying member method code with example usage: obj.test_custom_op_gradient(tol) and returns: unknown, qml