code: def apply_operation_tensordot(
      op: qml.operation.Operator, state, is_state_batched: bool = False
  ):
      """Apply ``Operator`` to ``state`` using ``math.tensordot``. This is more efficent at higher qubit
      numbers.
  
      Args:
          op (Operator): Operator to apply to the quantum state
          state (array[complex]): Input quantum state
          is_state_batched (bool): Boolean representing whether the state is batched or not
  
      Returns:
          array[complex]: output_state
      """
      mat = op.matrix()
      total_indices = len(state.shape) - is_state_batched
      num_indices = len(op.wires)
  
      new_mat_shape = [2] * (num_indices * 2)
      dim = 2**num_indices
      batch_size = math.get_batch_size(mat, (dim, dim), dim**2)
      if is_mat_batched := batch_size is not None:
          # Add broadcasting dimension to shape
          new_mat_shape = [batch_size] + new_mat_shape
          if op.batch_size is None:
              op._batch_size = (
                  batch_size  # pylint:disable=protected-access
              )
      reshaped_mat = math.reshape(mat, new_mat_shape)
  
      mat_axes = list(range(-num_indices, 0))
      state_axes = [i + is_state_batched for i in op.wires]
      axes = (mat_axes, state_axes)
  
      tdot = math.tensordot(reshaped_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 = [
          i for i in range(total_indices) if i not in op.wires
      ]
      perm = list(op.wires) + unused_idxs
      if is_mat_batched:
          perm = [0] + [i + 1 for i in perm]
      if is_state_batched:
          perm.insert(num_indices, -1)
  
      inv_perm = math.argsort(perm)
      return math.transpose(tdot, inv_perm)
  
imports: from functools import singledispatch
  from string import ascii_letters
  import numpy
  import pennylane
  from pennylane import math
label_desc: Use image node_id 3 for calling a global function with example usage: apply_operation_tensordot(op, state, is_state_batched) and returns: math