class_docstr: Tests the application and differentiation of an RX gate in the different interfaces.
class_docstr_tok: ["Tests","the","application","and","differentiation","of","an","RX","gate","in","the","different","interfaces","."]
docstr: Tests the application and differentiation of an rx gate with tensorflow
docstr_tok: ["Tests","the","application","and","differentiation","of","an","rx","gate","with","tensorflow"]
code: def test_rx_grad_tf(self, method):
      """Tests the application and differentiation of an rx gate with tensorflow"""
      import tensorflow as tf
  
      state = tf.Variable(self.state)
      phi = tf.Variable(0.8589 + 0j)
  
      with tf.GradientTape() as grad_tape:
          op = qml.RX(phi, wires=0)
          new_state = method(op, state)
  
      grads = grad_tape.jacobian(new_state, [phi])
      # tf takes gradient with respect to conj(z), so we need to conj the gradient
      phi_grad = tf.math.conj(grads[0])
  
      self.compare_expected_result(phi, state, new_state, phi_grad)
  
imports: from functools import reduce
  import pytest
  import numpy
  from scipy.stats import unitary_group
  import pennylane
  from pennylane.operation import _UNSET_BATCH_SIZE, Operation
  from pennylane.devices.qubit.apply_operation import apply_operation, apply_operation_einsum, apply_operation_tensordot
label_desc: Use image node_id 5 for calling the TestRXCalcGrad obj's underlying member method code with example usage: obj.test_rx_grad_tf(method) without return types