class_docstr: Tests that broadcasted operations are applied correctly.
class_docstr_tok: ["Tests","that","broadcasted","operations","are","applied","correctly","."]
docstr: Tests that unbatched operations are applied correctly to a batched state.
docstr_tok: ["Tests","that","unbatched","operations","are","applied","correctly","to","a","batched","state","."]
code: def test_broadcasted_state(self, op, method, ml_framework):
      """Tests that unbatched operations are applied correctly to a batched state."""
      state = np.ones((3, 2, 2, 2)) / np.sqrt(8)
  
      res = method(
          op,
          qml.math.asarray(state, like=ml_framework),
          is_state_batched=True,
      )
      missing_wires = 3 - len(op.wires)
      mat = op.matrix()
      expanded_mat = (
          np.kron(np.eye(2**missing_wires), mat)
          if missing_wires
          else mat
      )
      expected = [
          (expanded_mat @ state[i].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 2 for calling the TestBroadcasting obj's underlying member method code with example usage: obj.test_broadcasted_state(op, method, ml_framework) without return types