class_docstr: Tests that broadcasted operations are applied correctly.
class_docstr_tok: ["Tests","that","broadcasted","operations","are","applied","correctly","."]
docstr: Tests that batched operations are applied correctly to an unbatched state.
docstr_tok: ["Tests","that","batched","operations","are","applied","correctly","to","an","unbatched","state","."]
code: def test_broadcasted_op(self, op, method, ml_framework):
      """Tests that batched operations are applied correctly to an unbatched state."""
      state = np.ones((2, 2, 2)) / np.sqrt(8)
  
      res = method(op, qml.math.asarray(state, like=ml_framework))
      missing_wires = 3 - len(op.wires)
      mat = op.matrix()
      expanded_mat = [
          np.kron(np.eye(2**missing_wires), mat[i])
          if missing_wires
          else mat[i]
          for i in range(3)
      ]
      expected = [
          (expanded_mat[i] @ state.flatten()).reshape((2, 2, 2))
          for i in range(3)
      ]
  
      assert qml.math.get_interface(res) == ml_framework
      assert qml.math.allclose(res, expected)
  
imports: from functools import reduce
  import pytest
  import numpy
  from scipy.stats import unitary_group
  import pennylane
  from pennylane.operation import _UNSET_BATCH_SIZE, Operation
  from pennylane.devices.qubit.apply_operation import apply_operation, apply_operation_einsum, apply_operation_tensordot
label_desc: Use image node_id 1 for calling the TestBroadcasting obj's underlying member method code with example usage: obj.test_broadcasted_op(op, method, ml_framework) without return types