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.
  
  Args:
      state (array[complex]): input state
      mat (array): matrix to multiply
      wires (Wires): target wires
  
  Returns:
      array[complex]: output state
  
  Note: This function does not support simultaneously broadcasted states and matrices yet.
code: def _apply_unitary(self, state, mat, wires):
      r"""Apply multiplication of a matrix to subsystems of the quantum state.
  
      Args:
          state (array[complex]): input state
          mat (array): matrix to multiply
          wires (Wires): target wires
  
      Returns:
          array[complex]: output state
  
      Note: This function does not support simultaneously broadcasted states and matrices yet.
      """
      # translate to wire labels used by device
      device_wires = self.map_wires(wires)
  
      dim = 2 ** len(device_wires)
      mat_batch_size = self._get_batch_size(mat, (dim, dim), dim**2)
      state_batch_size = self._get_batch_size(
          state, (2,) * self.num_wires, 2**self.num_wires
      )
  
      shape = [2] * (len(device_wires) * 2)
      state_axes = device_wires
      # If the matrix is broadcasted, it is reshaped to have leading axis of size mat_batch_size
      if mat_batch_size:
          shape.insert(0, mat_batch_size)
          if state_batch_size:
              raise NotImplementedError(
                  "Applying a broadcasted unitary to an already broadcasted state via "
                  "_apply_unitary is not supported. Broadcasting sizes are "
                  f"({mat_batch_size}, {state_batch_size})."
              )
      # If the state is broadcasted, the affected state axes need to be shifted by 1.
      if state_batch_size:
          state_axes = [ax + 1 for ax in state_axes]
      mat = self._cast(self._reshape(mat, shape), dtype=self.C_DTYPE)
      axes = (np.arange(-len(device_wires), 0), state_axes)
      tdot = self._tensordot(mat, state, axes=axes)
  
      # tensordot causes the axes given in `wires` to end up in the first positions
      # of the resulting tensor. This corresponds to a (partial) transpose of
      # the correct output state
      # We'll need to invert this permutation to put the indices in the correct place
      unused_idxs = [
          idx
          for idx in range(self.num_wires)
          if idx not in device_wires
      ]
      perm = list(device_wires) + unused_idxs
      # If the matrix is broadcasted, all but the first dimension are shifted by 1
      if mat_batch_size:
          perm = [idx + 1 for idx in perm]
          perm.insert(0, 0)
      if state_batch_size:
          # As the state broadcasting dimension always is the first in the state, it always
          # ends up in position `len(device_wires)` after the tensordot. The -1 causes it
          # being permuted to the leading dimension after transposition
          perm.insert(len(device_wires), -1)
  
      inv_perm = np.argsort(perm)  # argsort gives inverse permutation
      return self._transpose(tdot, inv_perm)
  
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 29 for calling the DefaultQubitLegacy obj's underlying member method code with example usage: obj._apply_unitary(state, mat, wires) and returns: self