code: def sample(self, bqm, num_reads=10):
          
          values = tuple(bqm.vartype.value)
  
          def _itersample():
              for __ in range(num_reads):
                  sample = {v: choice(values) for v in bqm.linear}
                  energy = bqm.energy(sample)
  
                  yield sample, energy
  
          samples, energies = zip(*_itersample())
  
          return SampleSet.from_samples(samples, bqm.vartype, energies)
docs: Give random samples for a binary quadratic model.
  
          Variable assignments are chosen by coin flip.
  
          Args:
              bqm (:obj:`.BinaryQuadraticModel`):
                  Binary quadratic model to be sampled from.
  
              num_reads (int, optional, default=10):
                  Number of reads.
  
          Returns:
              :obj:`.SampleSet`