# Initialize a 2-mode circuit with cutoff=5
cir = dq.QumodeCircuit(2, 'vac', cutoff=5, backend='gaussian')
# Define trainable parameters
r0 = torch.nn.Parameter(torch.tensor(0.5))
r1 = torch.nn.Parameter(torch.tensor(1.0))
# Add squeezing gates
cir.s(0, r=r0)
cir.s(1, r=r1)
# Define trainable parameter for beamsplitter
theta = torch.nn.Parameter(torch.tensor(1.0))
# Add a beamsplitter gate
cir.bs([0, 1], inputs=[theta, 1])
# Forward process
cir()
# Print the measurement results
# with different detectors
sample = cir.measure(shots=100, detector='threshold')
print(sample)
Inconsistent sampling results of GBS with detector=
'threshold'using chain-rule methodcode: