class_docstr: Tests that the template defines the correct decomposition.
class_docstr_tok: ["Tests","that","the","template","defines","the","correct","decomposition","."]
docstr: Tests that the template produces states with correct probability distribution.
docstr_tok: ["Tests","that","the","template","produces","states","with","correct","probability","distribution","."]
code: def test_state_preparation_probability_distribution(
      self, tol, state_vector, wires, target_state
  ):
      """Tests that the template produces states with correct probability distribution."""
  
      @qml.qnode(qml.device("default.qubit", wires=3))
      def circuit():
          qml.MottonenStatePreparation(state_vector, wires)
          return (
              qml.expval(qml.PauliZ(0)),
              qml.expval(qml.PauliZ(1)),
              qml.expval(qml.PauliZ(2)),
              qml.state(),
          )
  
      results = circuit()
  
      state = results[-1].ravel()
  
      probabilities = np.abs(state) ** 2
      target_probabilities = np.abs(target_state) ** 2
  
      assert np.allclose(
          probabilities, target_probabilities, atol=tol, rtol=0
      )
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane import numpy
  from pennylane.templates.state_preparations.mottonen import gray_code, _get_alpha_y
label_desc: Use image node_id 2 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_state_preparation_probability_distribution(tol, state_vector, wires, target_state) and returns: qml,  qml,  qml,  qml