class_docstr: Tests for the state function
class_docstr_tok: ["Tests","for","the","state","function"]
docstr: Test that the correct state is returned when the circuit prepares a GHZ state
docstr_tok: ["Test","that","the","correct","state","is","returned","when","the","circuit","prepares","a","GHZ","state"]
code: def test_state_correct_ghz(self, wires):
      """Test that the correct state is returned when the circuit prepares a GHZ state"""
  
      dev = qml.device("default.qubit.legacy", wires=wires)
  
      @qml.qnode(dev)
      def func():
          qml.Hadamard(wires=0)
          for i in range(wires - 1):
              qml.CNOT(wires=[i, i + 1])
          return state()
  
      state_val = func()
      assert np.allclose(np.sum(np.abs(state_val) ** 2), 1)
      # pylint: disable=unsubscriptable-object
      assert np.allclose(state_val[0], 1 / np.sqrt(2))
      assert np.allclose(state_val[-1], 1 / np.sqrt(2))
  
      assert np.allclose(
          state().process_state(state=dev.state, wire_order=dev.wires),
          state_val,
      )
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.measurements import State, Shots, density_matrix, expval, state
label_desc: Use image node_id 3 for calling the TestState obj's underlying member method code with example usage: obj.test_state_correct_ghz(wires) and returns: state