from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite
sampler = DWaveSampler()
sampler_embedded = EmbeddingComposite(sampler)

Q = {('x', 'x'): -1, ('y', 'y'): -1, ('x', 'y'): 2}

response = sampler_embedded.sample_qubo(Q, num_reads=5000)
for datum in response.data(['sample', 'energy', 'num_occurrences']):   
  print(datum.sample, "Energy: ", datum.energy, "Occurrences: ", datum.num_occurrences)

#output:
#({'y': 1, 'x': 0}, 'Energy: ', -1.0, 'Occurrences: ', 2617)
#({'y': 0, 'x': 1}, 'Energy: ', -1.0, 'Occurrences: ', 2382)
#({'y': 0, 'x': 0}, 'Energy: ', 0.0, 'Occurrences: ', 1)
