code: def measure(
      wires: Wires,
      reset: Optional[bool] = False,
      postselect: Optional[int] = None,
  ):
      r"""Perform a mid-circuit measurement in the computational basis on the
      supplied qubit.
  
      Measurement outcomes can be obtained and used to conditionally apply
      operations.
  
      If a device doesn't support mid-circuit measurements natively, then the
      QNode will apply the :func:`defer_measurements` transform.
  
      **Example:**
  
      .. code-block:: python3
  
          dev = qml.device("default.qubit", wires=3)
  
          @qml.qnode(dev)
          def func(x, y):
              qml.RY(x, wires=0)
              qml.CNOT(wires=[0, 1])
              m_0 = qml.measure(1)
  
              qml.cond(m_0, qml.RY)(y, wires=0)
              return qml.probs(wires=[0])
  
      Executing this QNode:
  
      >>> pars = np.array([0.643, 0.246], requires_grad=True)
      >>> func(*pars)
      tensor([0.90165331, 0.09834669], requires_grad=True)
  
      Wires can be reused after measurement. Moreover, measured wires can be reset
      to the :math:`|0 \rangle` by setting ``reset=True``.
  
      .. code-block:: python3
  
          dev = qml.device("default.qubit", wires=3)
  
          @qml.qnode(dev)
          def func():
              qml.PauliX(1)
              m_0 = qml.measure(1, reset=True)
              return qml.probs(wires=[1])
  
      Executing this QNode:
  
      >>> func()
      tensor([1., 0.], requires_grad=True)
  
      Mid circuit measurements can be manipulated using the following arithmetic operators:
      ``+``, ``-``, ``*``, ``/``, ``~`` (not), ``&`` (and), ``|`` (or), ``==``, ``<=``,
      ``>=``, ``<``, ``>`` with other mid-circuit measurements or scalars.
  
      .. Note ::
  
          Python ``not``, ``and``, ``or``, do not work since these do not have dunder methods.
          Instead use ``~``, ``&``, ``|``.
  
      Args:
          wires (Wires): The wire of the qubit the measurement process applies to.
          reset (Optional[bool]): Whether to reset the wire to the :math:`|0 \rangle`
              state after measurement.
          postselect (Optional[int]): Which basis state to postselect after a mid-circuit
              measurement. None by default. If postselection is requested, only the post-measurement
              state that is used for postselection will be considered in the remaining circuit.
  
      Returns:
          MidMeasureMP: measurement process instance
  
      Raises:
          QuantumFunctionError: if multiple wires were specified
  
      .. details::
          :title: Postselection
  
          Postselection discards outcomes that do not meet the criteria provided by the ``postselect``
          argument. For example, specifying ``postselect=1`` on wire 0 would be equivalent to projecting
          the state vector onto the :math:`|1\rangle` state on wire 0:
  
          .. code-block:: python3
  
              dev = qml.device("default.qubit")
  
              @qml.qnode(dev)
              def func(x):
                  qml.RX(x, wires=0)
                  m0 = qml.measure(0, postselect=1)
                  qml.cond(m0, qml.PauliX)(wires=1)
                  return qml.sample(wires=1)
  
          By postselecting on ``1``, we only consider the ``1`` measurement outcome on wire 0. So, the probability of
          measuring ``1`` on wire 1 after postselection should also be 1. Executing this QNode with 10 shots:
  
          >>> func(np.pi / 2, shots=10)
          array([1, 1, 1, 1, 1, 1, 1])
  
          Note that only 7 samples are returned. This is because samples that do not meet the postselection criteria are
          thrown away.
  
          If postselection is requested on a state with zero probability of being measured, the result may contain ``NaN``
          or ``Inf`` values:
  
          .. code-block:: python3
  
              dev = qml.device("default.qubit")
  
              @qml.qnode(dev)
              def func(x):
                  qml.RX(x, wires=0)
                  m0 = qml.measure(0, postselect=1)
                  qml.cond(m0, qml.PauliX)(wires=1)
                  return qml.probs(wires=1)
  
          >>> func(0.0)
          tensor([nan, nan], requires_grad=True)
  
          In the case of ``qml.sample``, an empty array will be returned:
  
          .. code-block:: python3
  
              dev = qml.device("default.qubit")
  
              @qml.qnode(dev)
              def func(x):
                  qml.RX(x, wires=0)
                  m0 = qml.measure(0, postselect=1)
                  qml.cond(m0, qml.PauliX)(wires=1)
                  return qml.sample(wires=[0, 1])
  
          >>> func(0.0, shots=[10, 10])
          (array([], shape=(0, 2), dtype=int64), array([], shape=(0, 2), dtype=int64))
  
          .. note::
  
              Currently, postselection support is only available on ``default.qubit``. Using postselection
              on other devices will raise an error.
  
          .. warning::
  
              All measurements are supported when using postselection. However, postselection on a zero probability
              state can cause some measurements to break:
  
              * With finite shots, one must be careful when measuring ``qml.probs`` or ``qml.counts``, as these
                measurements will raise errors if there are no valid samples after postselection. This will occur
                with postselection states that have zero or close to zero probability.
  
              * With analytic execution, ``qml.mutual_info`` will raise errors when using any interfaces except
                ``jax``, and ``qml.vn_entropy`` will raise an error with the ``tensorflow`` interface when the
                postselection state has zero probability.
  
              * When using JIT, ``QNode``'s may have unexpected behaviour when postselection on a zero
                probability state is performed. Due to floating point precision, the zero probability may not be
                detected, thus letting execution continue as normal without ``NaN`` or ``Inf`` values or empty
                samples, leading to unexpected or incorrect results.
  
      """
  
      wire = Wires(wires)
      if len(wire) > 1:
          raise qml.QuantumFunctionError(
              "Only a single qubit can be measured in the middle of the circuit"
          )
  
      # Create a UUID and a map between MP and MV to support serialization
      measurement_id = str(uuid.uuid4())[:8]
      mp = MidMeasureMP(
          wires=wire,
          reset=reset,
          postselect=postselect,
          id=measurement_id,
      )
      return MeasurementValue([mp], processing_fn=lambda v: v)
  
imports: import uuid
  from typing import Generic, TypeVar, Optional
  import numpy
  import pennylane
  from pennylane.wires import Wires
  from .measurements import MeasurementProcess, MidMeasure
label_desc: Use image node_id 1 for calling a global function with example usage: measure(wires, reset, postselect) and returns: MeasurementValue