class_docstr: Default qutrit device for PennyLane.
  
  .. warning::
  
      The API of ``DefaultQutrit`` will be updated soon to follow a new device interface described
      in :class:`pennylane.devices.Device`.
  
      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","qutrit","device","for","PennyLane",".","..","warning",":",":","The","API","of","``","DefaultQutrit","``","will","be","updated","soon","to","follow","a","new","device","interface","described","in",":","class",":","`","pennylane.devices.Device","`",".","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: Applies a controlled ternary add gate by slicing along the first axis specified in ``axes`` and
  applying a TShift transformation along the second axis. The ternary add gate acts on the computational
  basis states like :math:`       ext{TAdd}ert i, j
  angle 
  ightarrow ert i, i+j 
  angle`, where addition
  is taken modulo 3.
  
  By slicing along the first axis, we are able to select all of the amplitudes with corresponding
  :math:`|1
  angle` and :math:`|2
  angle` for the control qutrit. This means we just need to apply
  a :class:`~.TShift` gate when slicing along index 1, and a :class:`~.TShift` adjoint gate when
  slicing along index 2
  
  Args:
      state (array[complex]): input state
      axes (List[int]): target axes to apply transformation
  
  Returns:
      array[complex]: output state
docstr_tok: ["Applies","a","controlled","ternary","add","gate","by","slicing","along","the","first","axis","specified","in","``","axes","``","and","applying","a","TShift","transformation","along","the","second","axis",".","The","ternary","add","gate","acts","on","the","computational","basis","states","like",":","math",":","`","ext","{","TAdd","}","ert","i",",","j","angle","ightarrow","ert","i",",","i+j","angle","`",",","where","addition","is","taken","modulo","3",".","By","slicing","along","the","first","axis",",","we","are","able","to","select","all","of","the","amplitudes","with","corresponding",":","math",":","`","|1","angle","`","and",":","math",":","`","|2","angle","`","for","the","control","qutrit",".","This","means","we","just","need","to","apply","a",":","class",":","`","~.TShift","`","gate","when","slicing","along","index","1",",","and","a",":","class",":","`","~.TShift","`","adjoint","gate","when","slicing","along","index","2","Args",":","state","(","array","[","complex","]",")",":","input","state","axes","(","List","[","int","]",")",":","target","axes","to","apply","transformation","Returns",":","array","[","complex","]",":","output","state"]
code: def _apply_tadd(self, state, axes, inverse=False):
      """Applies a controlled ternary add gate by slicing along the first axis specified in ``axes`` and
      applying a TShift transformation along the second axis. The ternary add gate acts on the computational
      basis states like :math:`\text{TAdd}\vert i, j\rangle \rightarrow \vert i, i+j \rangle`, where addition
      is taken modulo 3.
  
      By slicing along the first axis, we are able to select all of the amplitudes with corresponding
      :math:`|1\rangle` and :math:`|2\rangle` for the control qutrit. This means we just need to apply
      a :class:`~.TShift` gate when slicing along index 1, and a :class:`~.TShift` adjoint gate when
      slicing along index 2
  
      Args:
          state (array[complex]): input state
          axes (List[int]): target axes to apply transformation
  
      Returns:
          array[complex]: output state
      """
      slices = [
          _get_slice(i, axes[0], self.num_wires) for i in range(3)
      ]
  
      # We will be slicing into the state according to state[slices[1]] and state[slices[2]],
      # giving us all of the amplitudes with a |1> and |2> for the control qutrit. The resulting
      # array has lost an axis relative to state and we need to be careful about the axis we
      # roll. If axes[1] is larger than axes[0], then we need to shift the target axis down by
      # one, otherwise we can leave as-is. For example: a state has [0, 1, 2, 3], control=1,
      # target=3. Then, state[slices[1]] has 3 axes and target=3 now corresponds to the second axis.
      target_axes = [axes[1] - 1] if axes[1] > axes[0] else [axes[1]]
  
      state_1 = self._apply_tshift(
          state[slices[1]], axes=target_axes, inverse=inverse
      )
      state_2 = self._apply_tshift(
          state[slices[2]], axes=target_axes, inverse=not inverse
      )
      return self._stack(
          [state[slices[0]], state_1, state_2], axis=axes[0]
      )
  
imports: import functools
  import numpy
  import pennylane
  from pennylane import QutritDevice, QutritBasisState, DeviceError
  from pennylane.wires import WireError
  from pennylane.devices.default_qubit_legacy import _get_slice
  from .._version import __version__
label_desc: Use image node_id 11 for calling the DefaultQutrit obj's underlying member method code with example usage: obj._apply_tadd(state, axes, inverse) and returns: self