class_docstr: Test that single measurements return behavior does not change.
class_docstr_tok: ["Test","that","single","measurements","return","behavior","does","not","change","."]
docstr: Return density matrix.
docstr_tok: ["Return","density","matrix","."]
code: def test_density_matrix(self, d_wires, device, interface, shots):
      """Return density matrix."""
      dev = qml.device(device, wires=4, shots=shots)
  
      def circuit(x):
          qml.Hadamard(wires=[0])
          qml.CRX(x, wires=[0, 1])
          return qml.density_matrix(wires=range(0, d_wires))
  
      qnode = qml.QNode(circuit, dev)
      qnode.construct([0.5], {})
  
      if dev.shots is not None:
          with pytest.warns(
              UserWarning, match="with finite shots; the returned"
          ):
              res = qml.execute(
                  tapes=[qnode.tape],
                  device=dev,
                  gradient_fn=None,
                  interface=interface,
              )
      else:
          res = qml.execute(
              tapes=[qnode.tape],
              device=dev,
              gradient_fn=None,
              interface=interface,
          )
  
      assert res[0].shape == (2**d_wires, 2**d_wires)
      assert isinstance(res[0], np.ndarray)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.measurements import MeasurementProcess
label_desc: Use image node_id 3 for calling the TestSingleReturnExecute obj's underlying member method code with example usage: obj.test_density_matrix(d_wires, device, interface, shots) and returns: qml