class_docstr: Test the default gaussian device. The test ensures that the device is properly
  applying gaussian operations and calculating the correct observables.
class_docstr_tok: ["Test","the","default","gaussian","device",".","The","test","ensures","that","the","device","is","properly","applying","gaussian","operations","and","calculating","the","correct","observables","."]
docstr: test correct variance for number state expectation |<n|S(r)>|^2
  on a squeezed state
docstr_tok: ["test","correct","variance","for","number","state","expectation","|","<","n|S","(","r",")",">","|^2","on","a","squeezed","state"]
code: def test_variance_squeezed_numberstate(self, tol):
      """test correct variance for number state expectation |<n|S(r)>|^2
      on a squeezed state
      """
      dev = qml.device("default.gaussian", wires=1, hbar=hbar)
  
      n = 1
      r = 0.4523
      dev.apply("SqueezedState", wires=Wires([0]), par=[r, 0])
      var = dev.var(
          "FockStateProjector", Wires([0]), [np.array([2 * n])]
      )
      mean = (
          np.abs(
              np.sqrt(fac(2 * n))
              / (2**n * fac(n))
              * (-np.tanh(r)) ** n
              / np.sqrt(np.cosh(r))
          )
          ** 2
      )
      assert var == pytest.approx(mean * (1 - mean), abs=tol)
  
imports: import numpy
  import numpy.random
  import pytest
  from scipy.linalg import block_diag
  from scipy.special import factorial
  import pennylane
  from pennylane import DeviceError
  from pennylane.devices.default_gaussian import fock_prob, rotation, squeezing, quadratic_phase, beamsplitter, two_mode_squeezing, controlled_addition, controlled_phase, vacuum_state, coherent_state, squeezed_state, displaced_squeezed_state, thermal_state
  from pennylane.wires import Wires
label_desc: Use image node_id 12 for calling the TestDefaultGaussianDevice obj's underlying member method code with example usage: obj.test_variance_squeezed_numberstate(tol) without return types