class_docstr: Testing differentiability of classical fisher info matrix (CFIM)
class_docstr_tok: ["Testing","differentiability","of","classical","fisher","info","matrix","(","CFIM",")"]
docstr: Testing that the derivative of the cfim is giving consistently the same results for all interfaces.
  Currently failing as (jax and autograd) and (torch and tf) are giving two different results.
docstr_tok: ["Testing","that","the","derivative","of","the","cfim","is","giving","consistently","the","same","results","for","all","interfaces",".","Currently","failing","as","(","jax","and","autograd",")","and","(","torch","and","tf",")","are","giving","two","different","results","."]
code: def test_consistency(self):
      """Testing that the derivative of the cfim is giving consistently the same results for all interfaces.
      Currently failing as (jax and autograd) and (torch and tf) are giving two different results.
      """
      import tensorflow as tf
      import torch
      import jax.numpy as jnp
      import jax
  
      dev = qml.device("default.qubit", wires=3)
  
      def qfunc(weights):
          qml.RX(weights[0], wires=0)
          qml.RX(weights[1], wires=1)
          qml.RX(weights[2], wires=2)
          qml.CNOT(wires=[0, 1])
          qml.RY(weights[4], wires=0)
          qml.RY(weights[5], wires=1)
          qml.RY(weights[6], wires=2)
          qml.CNOT(wires=[1, 2])
          qml.CRX(weights[7], wires=[0, 1])
          qml.CRY(weights[8], wires=[1, 2])
          qml.CRZ(weights[9], wires=[2, 0])
          return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
  
      # Compute gradients of CFIM for different interfaces
      circuit = qml.QNode(qfunc, dev)
      weights = torch.tensor(
          [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
          requires_grad=True,
      )
      grad_torch = torch.autograd.functional.jacobian(
          qml.qinfo.classical_fisher(circuit), weights
      )
  
      circuit = qml.QNode(qfunc, dev)
      weights = pnp.array(
          [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
          requires_grad=True,
      )
      grad_autograd = qml.jacobian(qml.qinfo.classical_fisher(circuit))(
          weights
      )
  
      circuit = qml.QNode(qfunc, dev)
      weights = jnp.array(
          [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
      )
      grad_jax = jax.jacobian(qml.qinfo.classical_fisher(circuit))(
          weights
      )
  
      circuit = qml.QNode(qfunc, dev)
      weights = tf.Variable(
          [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
      )
      with tf.GradientTape() as tape:
          loss = qml.qinfo.classical_fisher(circuit)(weights)
      grad_tf = tape.jacobian(loss, weights)
  
      # Evaluate and compare
      grads = [grad_autograd, grad_tf, grad_torch, grad_jax]
  
      is_same = np.zeros((4, 4))
  
      for i, g1 in enumerate(grads):
          for j, g2 in enumerate(grads):
              is_same[i, j] = np.allclose(g1, g2, atol=1e-6)
  
      assert np.allclose(is_same, np.ones((4, 4)))
  
imports: import pytest
  import numpy
  import pennylane
  import pennylane.numpy
  from pennylane.qinfo import classical_fisher, quantum_fisher
  from pennylane.qinfo.transforms import _make_probs, _compute_cfim
label_desc: Use image node_id 5 for calling the TestDiffCFIM obj's underlying member method code with example usage: obj.test_consistency() and returns: qml