class_docstr: Default qubit device for PennyLane.
  
  .. warning::
  
      This is the legacy implementation of DefaultQubit. It has been replaced by
      ``qml.devices.DefaultQubit``, which can be accessed with the familiar constructor,
      ``qml.device("default.qubit")``.
  
      This change will not alter device behaviour for most workflows, but may have implications for
      plugin developers and users who directly interact with device methods. Please consult
      :class:`pennylane.devices.Device` and the implementation in
      :class:`pennylane.devices.DefaultQubit` for more information on what the new
      interface will look like and be prepared to make updates in a coming release. If you have any
      feedback on these changes, please create an
      `issue <https://github.com/PennyLaneAI/pennylane/issues>`_ or post in our
      `discussion forum <https://discuss.pennylane.ai/>`_.
  
  Args:
      wires (int, 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 (None, int): How many times the circuit should be evaluated (or sampled) to estimate
          the expectation values. Defaults to ``None`` if not specified, which means that the device
          returns analytical results.
class_docstr_tok: ["Default","qubit","device","for","PennyLane",".","..","warning",":",":","This","is","the","legacy","implementation","of","DefaultQubit",".","It","has","been","replaced","by","``","qml.devices.DefaultQubit","``",",","which","can","be","accessed","with","the","familiar","constructor",",","``","qml.device","(","``","default.qubit","''",")","``",".","This","change","will","not","alter","device","behaviour","for","most","workflows",",","but","may","have","implications","for","plugin","developers","and","users","who","directly","interact","with","device","methods",".","Please","consult",":","class",":","`","pennylane.devices.Device","`","and","the","implementation","in",":","class",":","`","pennylane.devices.DefaultQubit","`","for","more","information","on","what","the","new","interface","will","look","like","and","be","prepared","to","make","updates","in","a","coming","release",".","If","you","have","any","feedback","on","these","changes",",","please","create","an","`","issue","<","https",":","\/\/github.com\/PennyLaneAI\/pennylane\/issues",">","`","_","or","post","in","our","`","discussion","forum","<","https",":","\/\/discuss.pennylane.ai\/",">","`","_",".","Args",":","wires","(","int",",","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","(","None",",","int",")",":","How","many","times","the","circuit","should","be","evaluated","(","or","sampled",")","to","estimate","the","expectation","values",".","Defaults","to","``","None","``","if","not","specified",",","which","means","that","the","device","returns","analytical","results","."]
docstr: Apply multiplication of a matrix to subsystems of the quantum state.
  
  This function uses einsum instead of tensordot. This approach is only
  faster for single- and two-qubit gates.
  
  Args:
      state (array[complex]): input state
      mat (array): matrix to multiply
      wires (Wires): target wires
  
  Returns:
      array[complex]: output state
code: def _apply_unitary_einsum(self, state, mat, wires):
      r"""Apply multiplication of a matrix to subsystems of the quantum state.
  
      This function uses einsum instead of tensordot. This approach is only
      faster for single- and two-qubit gates.
  
      Args:
          state (array[complex]): input state
          mat (array): matrix to multiply
          wires (Wires): target wires
  
      Returns:
          array[complex]: output state
      """
      # translate to wire labels used by device
      device_wires = self.map_wires(wires)
  
      dim = 2 ** len(device_wires)
      batch_size = self._get_batch_size(mat, (dim, dim), dim**2)
  
      # If the matrix is broadcasted, it is reshaped to have leading axis of size mat_batch_size
      shape = [2] * (len(device_wires) * 2)
      if batch_size is not None:
          shape.insert(0, batch_size)
      mat = self._cast(self._reshape(mat, shape), dtype=self.C_DTYPE)
  
      # Tensor indices of the quantum state
      state_indices = ABC[: self.num_wires]
  
      # Indices of the quantum state affected by this operation
      affected_indices = "".join(ABC_ARRAY[list(device_wires)].tolist())
  
      # All affected indices will be summed over, so we need the same number of new indices
      new_indices = ABC[
          self.num_wires : self.num_wires + len(device_wires)
      ]
  
      # The new indices of the state are given by the old ones with the affected indices
      # replaced by the new_indices
      new_state_indices = functools.reduce(
          lambda old_string, idx_pair: old_string.replace(
              idx_pair[0], idx_pair[1]
          ),
          zip(affected_indices, new_indices),
          state_indices,
      )
  
      # We now put together the indices in the notation numpy's einsum requires
      # This notation allows for the state, the matrix, or both to be broadcasted
      einsum_indices = f"...{new_indices}{affected_indices},...{state_indices}->...{new_state_indices}"
  
      return self._einsum(einsum_indices, mat, state)
  
imports: import functools
  import itertools
  from string import ascii_letters
  from typing import List
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import BasisState, DeviceError, QubitDevice, StatePrep, Snapshot
  from pennylane.devices.qubit import measure
  from pennylane.operation import Operation
  from pennylane.ops import Sum
  from pennylane.ops.qubit.attributes import diagonal_in_z_basis
  from pennylane.pulse import ParametrizedEvolution
  from pennylane.measurements import ExpectationMP
  from pennylane.typing import TensorLike
  from pennylane.wires import WireError
  from .._version import __version__
label_desc: Use image node_id 30 for calling the DefaultQubitLegacy obj's underlying member method code with example usage: obj._apply_unitary_einsum(state, mat, wires) and returns: self