class_docstr: Abstract base class for PennyLane devices.
  
  Args:
      wires (int or Iterable[Number, str]]): Number of subsystems represented by the device,
          or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
          or strings (``['ancilla', 'q1', 'q2']``). Default 1 if not specified.
      shots (int): Number of circuit evaluations/random samples used to estimate
          expectation values of observables. Defaults to 1000 if not specified.
class_docstr_tok: ["Abstract","base","class","for","PennyLane","devices",".","Args",":","wires","(","int","or","Iterable","[","Number",",","str","]","]",")",":","Number","of","subsystems","represented","by","the","device",",","or","iterable","that","contains","unique","labels","for","the","subsystems","as","numbers","(","i.e.",",","``","[","-1",",","0",",","2","]","``",")","or","strings","(","``","[","'ancilla","'",",","'q1","'",",","'q2","'","]","``",")",".","Default","1","if","not","specified",".","shots","(","int",")",":","Number","of","circuit","evaluations\/random","samples","used","to","estimate","expectation","values","of","observables",".","Defaults","to","1000","if","not","specified","."]
docstr: Execute a queue of quantum operations on the device and then measure the given observables.
  
  For plugin developers: Instead of overwriting this, consider implementing a suitable subset of
  :meth:`pre_apply`, :meth:`apply`, :meth:`post_apply`, :meth:`pre_measure`,
  :meth:`expval`, :meth:`var`, :meth:`sample`, :meth:`post_measure`, and :meth:`execution_context`.
  
  Args:
      queue (Iterable[~.operation.Operation]): operations to execute on the device
      observables (Iterable[~.operation.Observable]): observables to measure and return
      parameters (dict[int, list[ParameterDependency]]): Mapping from free parameter index to the list of
          :class:`Operations <pennylane.operation.Operation>` (in the queue) that depend on it.
  
  Keyword Args:
      return_native_type (bool): If True, return the result in whatever type the device uses
          internally, otherwise convert it into array[float]. Default: False.
  
  Raises:
      QuantumFunctionError: if the value of :attr:`~.Observable.return_type` is not supported
  
  Returns:
      array[float]: measured value(s)
docstr_tok: ["Execute","a","queue","of","quantum","operations","on","the","device","and","then","measure","the","given","observables",".","For","plugin","developers",":","Instead","of","overwriting","this",",","consider","implementing","a","suitable","subset","of",":","meth",":","`","pre_apply","`",",",":","meth",":","`","apply","`",",",":","meth",":","`","post_apply","`",",",":","meth",":","`","pre_measure","`",",",":","meth",":","`","expval","`",",",":","meth",":","`","var","`",",",":","meth",":","`","sample","`",",",":","meth",":","`","post_measure","`",",","and",":","meth",":","`","execution_context","`",".","Args",":","queue","(","Iterable","[","~.operation.Operation","]",")",":","operations","to","execute","on","the","device","observables","(","Iterable","[","~.operation.Observable","]",")",":","observables","to","measure","and","return","parameters","(","dict","[","int",",","list","[","ParameterDependency","]","]",")",":","Mapping","from","free","parameter","index","to","the","list","of",":","class",":","`","Operations","<","pennylane.operation.Operation",">","`","(","in","the","queue",")","that","depend","on","it",".","Keyword","Args",":","return_native_type","(","bool",")",":","If","True",",","return","the","result","in","whatever","type","the","device","uses","internally",",","otherwise","convert","it","into","array","[","float","]",".","Default",":","False",".","Raises",":","QuantumFunctionError",":","if","the","value","of",":","attr",":","`","~.Observable.return_type","`","is","not","supported","Returns",":","array","[","float","]",":","measured","value","(","s",")"]
code: def execute(self, queue, observables, parameters=None, **kwargs):
      """Execute a queue of quantum operations on the device and then measure the given observables.
  
      For plugin developers: Instead of overwriting this, consider implementing a suitable subset of
      :meth:`pre_apply`, :meth:`apply`, :meth:`post_apply`, :meth:`pre_measure`,
      :meth:`expval`, :meth:`var`, :meth:`sample`, :meth:`post_measure`, and :meth:`execution_context`.
  
      Args:
          queue (Iterable[~.operation.Operation]): operations to execute on the device
          observables (Iterable[~.operation.Observable]): observables to measure and return
          parameters (dict[int, list[ParameterDependency]]): Mapping from free parameter index to the list of
              :class:`Operations <pennylane.operation.Operation>` (in the queue) that depend on it.
  
      Keyword Args:
          return_native_type (bool): If True, return the result in whatever type the device uses
              internally, otherwise convert it into array[float]. Default: False.
  
      Raises:
          QuantumFunctionError: if the value of :attr:`~.Observable.return_type` is not supported
  
      Returns:
          array[float]: measured value(s)
      """
      self.check_validity(queue, observables)
      self._op_queue = queue
      self._obs_queue = observables
      self._parameters = {}
      if parameters is not None:
          self._parameters.update(parameters)
  
      results = []
      if self._shot_vector is not None:
          # The following warning assumes that QubitDevice.execute is stand-alone
          warnings.warn(
              "Specifying a list of shots is only supported for "
              "QubitDevice based devices. Falling back to executions using all shots in the shot list."
          )
  
      with self.execution_context():
          self.pre_apply()
  
          for operation in queue:
              self.apply(
                  operation.name, operation.wires, operation.parameters
              )
  
          self.post_apply()
  
          self.pre_measure()
  
          for mp in observables:
              obs = (
                  mp.obs
                  if isinstance(mp, MeasurementProcess)
                  and mp.obs is not None
                  else mp
              )
              if isinstance(obs, Tensor):
                  wires = [ob.wires for ob in obs.obs]
              else:
                  wires = obs.wires
  
              if mp.return_type is Expectation:
                  results.append(
                      self.expval(obs.name, wires, obs.parameters)
                  )
  
              elif mp.return_type is Variance:
                  results.append(
                      self.var(obs.name, wires, obs.parameters)
                  )
  
              elif mp.return_type is Sample:
                  results.append(
                      np.array(
                          self.sample(obs.name, wires, obs.parameters)
                      )
                  )
  
              elif mp.return_type is Probability:
                  results.append(
                      list(self.probability(wires=wires).values())
                  )
  
              elif mp.return_type is State:
                  raise qml.QuantumFunctionError(
                      "Returning the state is not supported"
                  )
  
              elif mp.return_type is not None:
                  raise qml.QuantumFunctionError(
                      f"Unsupported return type specified for observable {obs.name}"
                  )
  
          self.post_measure()
  
          self._op_queue = None
          self._obs_queue = None
          self._parameters = None
  
          # increment counter for number of executions of device
          self._num_executions += 1
  
          if self.tracker.active:
              self.tracker.update(
                  executions=1,
                  shots=self._shots,
                  results=self._asarray(results),
              )
              self.tracker.record()
  
          # Ensures that a combination with sample does not put
          # expvals and vars in superfluous arrays
          if all(mp.return_type is Sample for mp in observables):
              return self._asarray(results)
          if any(mp.return_type is Sample for mp in observables):
              return self._asarray(results, dtype="object")
  
          return self._asarray(results)
  
imports: import abc
  import copy
  import types
  import warnings
  from collections import OrderedDict
  from collections.abc import Iterable, Sequence
  from functools import lru_cache
  import numpy
  import pennylane
  from pennylane.measurements import MeasurementProcess, CountsMP, Expectation, ExpectationMP, MidMeasureMP, Probability, ProbabilityMP, Sample, SampleMP, ShadowExpvalMP, State, Variance
  from pennylane.operation import Observable, Operation, Tensor, Operator, StatePrepBase
  from pennylane.ops import Hamiltonian, Sum
  from pennylane.tape import QuantumScript, QuantumTape, expand_tape_state_prep
  from pennylane.wires import WireError, Wires
  from pennylane.queuing import QueuingManager
label_desc: Use image node_id 23 for calling the Device obj's underlying member method code with example usage: obj.execute(queue, observables, parameters) and returns: self, self, self