code: def from_qubo(cls, Q, offset=0.0):
          
          linear = {}
          quadratic = {}
          for (u, v), bias in iteritems(Q):
              if u == v:
                  linear[u] = bias
              else:
                  quadratic[(u, v)] = bias
  
          return cls(linear, quadratic, offset, Vartype.BINARY)
docs: Create a binary quadratic model from a QUBO model.
  
          Args:
              Q (dict):
                  Coefficients of a quadratic unconstrained binary optimization
                  (QUBO) problem. Should be a dict of the form `{(u, v): bias, ...}`
                  where `u`, `v`, are binary-valued variables and `bias` is their
                  associated coefficient.
  
              offset (optional, default=0.0):
                  Constant offset applied to the model.
  
          Returns:
              :class:`.BinaryQuadraticModel`: Binary quadratic model with vartype set to
              :class:`.Vartype.BINARY`.
  
          Examples:
              This example creates a binary quadratic model from a QUBO model.
  
              >>> import dimod
              >>> Q = {(0, 0): -1, (1, 1): -1, (0, 1): 2}
              >>> model = dimod.BinaryQuadraticModel.from_qubo(Q, offset = 0.0)
              >>> model.linear    # doctest: +SKIP
              {0: -1, 1: -1}
              >>> model.vartype
              <Vartype.BINARY: frozenset({0, 1})>