class_docstr: Test that a device different to default.qubit gives the same result
docstr: Compare a four-qubit random circuit with lots of different gates to default.qubit
docstr_tok: ["Compare","a","four-qubit","random","circuit","with","lots","of","different","gates","to","default.qubit"]
code: def test_four_qubit_random_circuit(self, device, tol):
      """Compare a four-qubit random circuit with lots of different gates to default.qubit"""
      n_wires = 4
      dev = device(n_wires)
      dev_def = qml.device("default.qubit", wires=n_wires)
  
      if dev.name == dev_def.name:
          pytest.skip("Device is default.qubit.")
  
      if dev.shots is not None:
          pytest.skip("Device is in non-analytical mode.")
  
      gates = [
          qml.PauliX(wires=0),
          qml.PauliY(wires=1),
          qml.PauliZ(wires=2),
          qml.S(wires=3),
          qml.T(wires=0),
          qml.RX(2.3, wires=1),
          qml.RY(1.3, wires=2),
          qml.RZ(3.3, wires=3),
          qml.Hadamard(wires=0),
          qml.Rot(0.1, 0.2, 0.3, wires=1),
          qml.CRot(0.1, 0.2, 0.3, wires=[2, 3]),
          qml.Toffoli(wires=[0, 1, 2]),
          qml.SWAP(wires=[1, 2]),
          qml.CSWAP(wires=[1, 2, 3]),
          qml.U1(1.0, wires=0),
          qml.U2(1.0, 2.0, wires=2),
          qml.U3(1.0, 2.0, 3.0, wires=3),
          qml.CRX(0.1, wires=[1, 2]),
          qml.CRY(0.2, wires=[2, 3]),
          qml.CRZ(0.3, wires=[3, 1]),
      ]
  
      layers = 3
      np.random.seed(1967)
      gates_per_layers = [
          np.random.permutation(gates).numpy() for _ in range(layers)
      ]
  
      def circuit():
          """4-qubit circuit with layers of randomly selected gates and random connections for
          multi-qubit gates."""
          np.random.seed(1967)
          for gates in gates_per_layers:
              for gate in gates:
                  qml.apply(gate)
          return qml.expval(qml.PauliZ(0))
  
      qnode_def = qml.QNode(circuit, dev_def)
      qnode = qml.QNode(circuit, dev)
  
      assert np.allclose(qnode(), qnode_def(), atol=tol(dev.shots))
  
file_path: pennylane/pennylane/devices/tests/test_compare_default_qubit.py
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
  from pennylane.templates.layers import RandomLayers
label_desc: Use image node_id 5 for calling the TestComparison obj's underlying member method code with example usage: obj.test_four_qubit_random_circuit(device, tol) and returns: qml