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: Apply a differentiable batch transform for preprocessing a circuit
  prior to execution. This method is called directly by the QNode, and
  should be overwritten if the device requires a transform that
  generates multiple circuits prior to execution.
  
  By default, this method contains logic for generating multiple
  circuits, one per term, of a circuit that terminates in ``expval(H)``,
  if the underlying device does not support Hamiltonian expectation values,
  or if the device requires finite shots.
  
  .. warning::
  
      This method will be tracked by autodifferentiation libraries,
      such as Autograd, JAX, TensorFlow, and Torch. Please make sure
      to use ``qml.math`` for autodiff-agnostic tensor processing
      if required.
  
  Args:
      circuit (.QuantumTape): the circuit to preprocess
  
  Returns:
      tuple[Sequence[.QuantumTape], callable]: Returns a tuple containing
      the sequence of circuits to be executed, and a post-processing function
      to be applied to the list of evaluated circuit results.
docstr_tok: ["Apply","a","differentiable","batch","transform","for","preprocessing","a","circuit","prior","to","execution",".","This","method","is","called","directly","by","the","QNode",",","and","should","be","overwritten","if","the","device","requires","a","transform","that","generates","multiple","circuits","prior","to","execution",".","By","default",",","this","method","contains","logic","for","generating","multiple","circuits",",","one","per","term",",","of","a","circuit","that","terminates","in","``","expval","(","H",")","``",",","if","the","underlying","device","does","not","support","Hamiltonian","expectation","values",",","or","if","the","device","requires","finite","shots",".","..","warning",":",":","This","method","will","be","tracked","by","autodifferentiation","libraries",",","such","as","Autograd",",","JAX",",","TensorFlow",",","and","Torch",".","Please","make","sure","to","use","``","qml.math","``","for","autodiff-agnostic","tensor","processing","if","required",".","Args",":","circuit","(",".QuantumTape",")",":","the","circuit","to","preprocess","Returns",":","tuple","[","Sequence","[",".QuantumTape","]",",","callable","]",":","Returns","a","tuple","containing","the","sequence","of","circuits","to","be","executed",",","and","a","post-processing","function","to","be","applied","to","the","list","of","evaluated","circuit","results","."]
code: def batch_transform(self, circuit: QuantumTape):
      """Apply a differentiable batch transform for preprocessing a circuit
      prior to execution. This method is called directly by the QNode, and
      should be overwritten if the device requires a transform that
      generates multiple circuits prior to execution.
  
      By default, this method contains logic for generating multiple
      circuits, one per term, of a circuit that terminates in ``expval(H)``,
      if the underlying device does not support Hamiltonian expectation values,
      or if the device requires finite shots.
  
      .. warning::
  
          This method will be tracked by autodifferentiation libraries,
          such as Autograd, JAX, TensorFlow, and Torch. Please make sure
          to use ``qml.math`` for autodiff-agnostic tensor processing
          if required.
  
      Args:
          circuit (.QuantumTape): the circuit to preprocess
  
      Returns:
          tuple[Sequence[.QuantumTape], callable]: Returns a tuple containing
          the sequence of circuits to be executed, and a post-processing function
          to be applied to the list of evaluated circuit results.
      """
      supports_hamiltonian = self.supports_observable("Hamiltonian")
      supports_sum = self.supports_observable("Sum")
      finite_shots = self.shots is not None
      grouping_known = all(
          obs.grouping_indices is not None
          for obs in circuit.observables
          if isinstance(obs, Hamiltonian)
      )
      # device property present in braket plugin
      use_grouping = getattr(self, "use_grouping", True)
  
      hamiltonian_in_obs = any(
          isinstance(obs, Hamiltonian) for obs in circuit.observables
      )
      expval_sum_in_obs = any(
          isinstance(m.obs, Sum) and isinstance(m, ExpectationMP)
          for m in circuit.measurements
      )
  
      is_shadow = any(
          isinstance(m, ShadowExpvalMP) for m in circuit.measurements
      )
  
      hamiltonian_unusable = not supports_hamiltonian or (
          finite_shots and not is_shadow
      )
  
      if hamiltonian_in_obs and (
          hamiltonian_unusable or (use_grouping and grouping_known)
      ):
          # If the observable contains a Hamiltonian and the device does not
          # support Hamiltonians, or if the simulation uses finite shots, or
          # if the Hamiltonian explicitly specifies an observable grouping,
          # split tape into multiple tapes of diagonalizable known observables.
          try:
              (
                  circuits,
                  hamiltonian_fn,
              ) = qml.transforms.hamiltonian_expand(
                  circuit, group=False
              )
          except ValueError as e:
              raise ValueError(
                  "Can only return the expectation of a single Hamiltonian observable"
              ) from e
      elif expval_sum_in_obs and not is_shadow and not supports_sum:
          circuits, hamiltonian_fn = qml.transforms.sum_expand(circuit)
  
      elif (
          len(circuit._obs_sharing_wires) > 0
          and not hamiltonian_in_obs
          and all(
              not isinstance(m, (SampleMP, ProbabilityMP, CountsMP))
              for m in circuit.measurements
          )
      ):
          # Check for case of non-commuting terms and that there are no Hamiltonians
          # TODO: allow for Hamiltonians in list of observables as well.
          circuits, hamiltonian_fn = qml.transforms.split_non_commuting(
              circuit
          )
  
      else:
          # otherwise, return the output of an identity transform
          circuits = [circuit]
  
          def hamiltonian_fn(res):
              return res[0]
  
      # Check whether the circuit was broadcasted (then the Hamiltonian-expanded
      # ones will be as well) and whether broadcasting is supported
      if circuit.batch_size is None or self.capabilities().get(
          "supports_broadcasting"
      ):
          # If the circuit wasn't broadcasted or broadcasting is supported, no action required
          return circuits, hamiltonian_fn
  
      # Expand each of the broadcasted Hamiltonian-expanded circuits
      expanded_tapes, expanded_fn = qml.transforms.map_batch_transform(
          qml.transforms.broadcast_expand, circuits
      )
  
      # Chain the postprocessing functions of the broadcasted-tape expansions and the Hamiltonian
      # expansion. Note that the application order is reversed compared to the expansion order,
      # i.e. while we first applied `hamiltonian_expand` to the tape, we need to process the
      # results from the broadcast expansion first.
      def total_processing(results):
          return hamiltonian_fn(expanded_fn(results))
  
      return expanded_tapes, total_processing
  
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 31 for calling the Device obj's underlying member method code with example usage: obj.batch_transform(circuit) and returns: expanded_tapes,  total_processing, circuits,  hamiltonian_fn, hamiltonian_fn, res