class_docstr: Test tensor expectation values
class_docstr_tok: ["Test","tensor","expectation","values"]
docstr: Test that when given a tensor observable the expectation value is the same regardless of how the
  wires are labelled, as long as they match the device order.
  
  For example:
  
  dev1 = qml.device("default.qubit", wires=[0, 1, 2])
  dev2 = qml.device("default.qubit", wires=['c', 'b', 'a']
  
  def circ(wire_labels):
      return qml.expval(qml.PauliZ(wires=wire_labels[0]) @ qml.PauliX(wires=wire_labels[2]))
  
  c1, c2 = qml.QNode(circ, dev1), qml.QNode(circ, dev2)
  c1([0, 1, 2]) == c2(['c', 'b', 'a'])
code: def test_wire_label_in_tensor_prod_observables(
      self, device, label_map, tol, skip_if
  ):
      """Test that when given a tensor observable the expectation value is the same regardless of how the
      wires are labelled, as long as they match the device order.
  
      For example:
  
      dev1 = qml.device("default.qubit", wires=[0, 1, 2])
      dev2 = qml.device("default.qubit", wires=['c', 'b', 'a']
  
      def circ(wire_labels):
          return qml.expval(qml.PauliZ(wires=wire_labels[0]) @ qml.PauliX(wires=wire_labels[2]))
  
      c1, c2 = qml.QNode(circ, dev1), qml.QNode(circ, dev2)
      c1([0, 1, 2]) == c2(['c', 'b', 'a'])
      """
      dev = device(wires=3)
      dev_custom_labels = device(wires=label_map)
      skip_if(dev, {"supports_tensor_observables": False})
  
      def circ(wire_labels):
          sub_routine(wire_labels)
          return qml.expval(
              qml.PauliX(wire_labels[0])
              @ qml.PauliY(wire_labels[1])
              @ qml.PauliZ(wire_labels[2])
          )
  
      circ_base_label = qml.QNode(circ, device=dev)
      circ_custom_label = qml.QNode(circ, device=dev_custom_labels)
  
      assert np.allclose(
          circ_base_label(wire_labels=range(3)),
          circ_custom_label(wire_labels=label_map),
          atol=tol(dev.shots),
          rtol=0,
      )
  
imports: import pytest
  from flaky import flaky
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
  from pennylane.measurements import ClassicalShadowMP, MeasurementTransform, SampleMeasurement, SampleMP, StateMeasurement, StateMP
label_desc: Use image node_id 4 for calling the TestTensorExpval obj's underlying member method code with example usage: obj.test_wire_label_in_tensor_prod_observables(device, label_map, tol, skip_if) and returns: qml