class_docstr: Tests for the expand_matrix helper function.
class_docstr_tok: ["Tests","for","the","expand_matrix","helper","function","."]
docstr: Tests the case where the broadcasted original matrix is expanded
docstr_tok: ["Tests","the","case","where","the","broadcasted","original","matrix","is","expanded"]
code: def test_expansion_broadcasted(self):
      """Tests the case where the broadcasted original matrix is expanded"""
      res = qml.math.expand_matrix(
          self.base_matrix_1_broadcasted, wires=[2], wire_order=[0, 2]
      )
      expected = np.array(
          [
              [
                  [1, 2, 0, 0],
                  [3, 4, 0, 0],
                  [0, 0, 1, 2],
                  [0, 0, 3, 4],
              ],
              [
                  [5, 6, 0, 0],
                  [7, 8, 0, 0],
                  [0, 0, 5, 6],
                  [0, 0, 7, 8],
              ],
              [
                  [9, 10, 0, 0],
                  [11, 12, 0, 0],
                  [0, 0, 9, 10],
                  [0, 0, 11, 12],
              ],
          ]
      )
      assert np.allclose(expected, res)
  
      res = qml.math.expand_matrix(
          self.base_matrix_1_broadcasted, wires=[2], wire_order=[2, 0]
      )
      expected = np.array(
          [
              [
                  [1, 0, 2, 0],
                  [0, 1, 0, 2],
                  [3, 0, 4, 0],
                  [0, 3, 0, 4],
              ],
              [
                  [5, 0, 6, 0],
                  [0, 5, 0, 6],
                  [7, 0, 8, 0],
                  [0, 7, 0, 8],
              ],
              [
                  [9, 0, 10, 0],
                  [0, 9, 0, 10],
                  [11, 0, 12, 0],
                  [0, 11, 0, 12],
              ],
          ]
      )
      assert np.allclose(expected, res)
  
imports: from functools import reduce
  import numpy
  import pytest
  from gate_data import CNOT, II, SWAP, I, Toffoli
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 7 for calling the TestExpandMatrix obj's underlying member method code with example usage: obj.test_expansion_broadcasted() without return types