class_docstr: Tests for the QuantumMonteCarlo template
class_docstr_tok: ["Tests","for","the","QuantumMonteCarlo","template"]
docstr: Test that the QuantumMonteCarlo template can correctly estimate the expectation value
  following the example in the usage details when the wires have custom labels
docstr_tok: ["Test","that","the","QuantumMonteCarlo","template","can","correctly","estimate","the","expectation","value","following","the","example","in","the","usage","details","when","the","wires","have","custom","labels"]
code: def test_expected_value_custom_wires(self):
      """Test that the QuantumMonteCarlo template can correctly estimate the expectation value
      following the example in the usage details when the wires have custom labels
      """
      m = 5
      M = 2**m
  
      xmax = np.pi
      xs = np.linspace(-xmax, xmax, M)
  
      probs = np.array([norm().pdf(x) for x in xs])
      probs /= np.sum(probs)
  
      func = lambda i: np.cos(xs[i]) ** 2
  
      n = 10
      N = 2**n
  
      target_wires = [0, "a", -1.1, -10, "bbb", 1000]
      estimation_wires = [
          "bob",
          -3,
          42,
          "penny",
          "lane",
          247,
          "straw",
          "berry",
          5.5,
          6.6,
      ]
  
      dev = qml.device(
          "default.qubit", wires=target_wires + estimation_wires
      )
  
      @qml.qnode(dev)
      def circuit():
          qml.QuantumMonteCarlo(
              probs,
              func,
              target_wires=target_wires,
              estimation_wires=estimation_wires,
          )
          return qml.probs(estimation_wires)
  
      phase_estimated = np.argmax(circuit()[: int(N / 2)]) / N
      mu_estimated = (1 - np.cos(np.pi * phase_estimated)) / 2
  
      exact = 0.432332358381693654
      assert np.allclose(mu_estimated, exact, rtol=1e-3)
  
imports: import numpy
  import pytest
  from scipy.stats import norm
  import pennylane
  from pennylane.templates.subroutines.qmc import QuantumMonteCarlo, _make_V, _make_Z, func_to_unitary, make_Q, probs_to_unitary
  from pennylane.wires import Wires
label_desc: Use image node_id 9 for calling the TestQuantumMonteCarlo obj's underlying member method code with example usage: obj.test_expected_value_custom_wires() and returns: qml