code: def expval(op: Union[Operator, MeasurementValue]):
      r"""Expectation value of the supplied observable.
  
      **Example:**
  
      .. code-block:: python3
  
          dev = qml.device("default.qubit", wires=2)
  
          @qml.qnode(dev)
          def circuit(x):
              qml.RX(x, wires=0)
              qml.Hadamard(wires=1)
              qml.CNOT(wires=[0, 1])
              return qml.expval(qml.PauliY(0))
  
      Executing this QNode:
  
      >>> circuit(0.5)
      -0.4794255386042029
  
      Args:
          op (Union[Observable, MeasurementValue]): a quantum observable object. To
              get expectation values for mid-circuit measurements, ``op`` should be
              a ``MeasurementValue``.
  
      Returns:
          ExpectationMP: measurement process instance
      """
      if isinstance(op, MeasurementValue):
          return ExpectationMP(obs=op)
  
      if isinstance(op, Sequence):
          raise ValueError(
              "qml.expval does not support measuring sequences of measurements or observables"
          )
  
      if not op.is_hermitian:
          warnings.warn(f"{op.name} might not be hermitian.")
  
      return ExpectationMP(obs=op)
  
file_path: pennylane/pennylane/measurements/expval.py
imports: import warnings
  from typing import Sequence, Tuple, Union
  import pennylane
  from pennylane.operation import Operator
  from pennylane.wires import Wires
  from .measurements import Expectation, SampleMeasurement, StateMeasurement
  from .mid_measure import MeasurementValue
label_desc: Use image node_id 1 for calling a global function with example usage: expval(op) and returns: ExpectationMP, ExpectationMP