code: def bqm_structured(f):
      
  
      @wraps(f)
      def new_f(sampler, bqm, **kwargs):
          try:
              structure = sampler.structure
              adjacency = structure.adjacency
          except AttributeError:
              if isinstance(sampler, Structured):
                  raise RuntimeError("something is wrong with the structured sampler")
              else:
                  raise TypeError("sampler does not have a structure property")
  
          if not all(v in adjacency for v in bqm.linear):
              # todo: better error message
              raise BinaryQuadraticModelStructureError("given bqm does not match the sampler's structure")
          if not all(u in adjacency[v] for u, v in bqm.quadratic):
              # todo: better error message
              raise BinaryQuadraticModelStructureError("given bqm does not match the sampler's structure")
  
          return f(sampler, bqm, **kwargs)
  
      return new_f
docs: Decorator to raise an error if the given bqm does not match the sampler's
      structure.
  
      Designed to be applied to :meth:`.Sampler.sample`. Expects the wrapped
      function or method to accept a :obj:`.BinaryQuadraticModel` as the second
      input and for the :class:`.Sampler` to also be :class:`.Structured`.