code: def test_apply_controlled_z(n_wires):
      """Test if the _apply_controlled_z performs the correct transformation by reconstructing the
      unitary and comparing against the one provided in _make_Z."""
      n_all_wires = n_wires + 1
  
      wires = Wires(range(n_wires))
      control_wire = n_wires
      work_wires = None
  
      circ = lambda: _apply_controlled_z(
          wires=wires, control_wire=control_wire, work_wires=work_wires
      )
      u = get_unitary(circ, n_all_wires)
  
      # Note the sign flip in the following. The sign does not matter when performing the Q unitary
      # because two Zs are used.
      z_ideal = -_make_Z(2**n_wires)
  
      circ = lambda: qml.ControlledQubitUnitary(
          z_ideal, wires=wires, control_wires=control_wire
      )
      u_ideal = get_unitary(circ, n_all_wires)
  
      assert np.allclose(u, u_ideal)
  
file_path: pennylane/tests/transforms/test_qmc_transform.py
imports: import itertools
  import numpy
  import pytest
  from scipy.stats import unitary_group, norm
  import pennylane
  from pennylane.transforms.qmc import _apply_controlled_z, _apply_controlled_v, apply_controlled_Q, quantum_monte_carlo
  from pennylane.templates.subroutines.qmc import _make_V, _make_Z, make_Q
  from pennylane.wires import Wires
label_desc: Use image node_id 3 for calling a global function with example usage: test_apply_controlled_z(n_wires) without return types