code: def to_numpy_vectors(self, variable_order=None, dtype=np.float, index_dtype=np.int64, sort_indices=False):
          linear = self.linear
          quadratic = self.quadratic
          num_variables = len(linear)
          num_interactions = len(quadratic)
          irow = np.empty(num_interactions, dtype=index_dtype)
          icol = np.empty(num_interactions, dtype=index_dtype)
          qdata = np.empty(num_interactions, dtype=dtype)
          if variable_order is None:
              try:
                  ldata = np.fromiter((linear[v] for v in range(num_variables)), count=num_variables, dtype=dtype)
              except KeyError:
                  raise ValueError(("if 'variable_order' is not provided, binary quadratic model must be "
                                    "index labeled [0, ..., N-1]"))
              for idx, ((u, v), bias) in enumerate(quadratic.items()):
                  irow[idx] = u
                  icol[idx] = v
                  qdata[idx] = bias
          else:
              try:
                  ldata = np.fromiter((linear[v] for v in variable_order), count=num_variables, dtype=dtype)
              except KeyError:
                  raise ValueError("provided 'variable_order' does not match binary quadratic model")
              label_to_idx = {v: idx for idx, v in enumerate(variable_order)}
              for idx, ((u, v), bias) in enumerate(quadratic.items()):
                  irow[idx] = label_to_idx[u]
                  icol[idx] = label_to_idx[v]
                  qdata[idx] = bias
          if sort_indices:
              swaps = irow > icol
              if swaps.any():
                  irow[swaps], icol[swaps] = icol[swaps], irow[swaps]
              order = np.lexsort((irow, icol))
              if not (order == range(len(order))).all():
                  irow = irow[order]
                  icol = icol[order]
                  qdata = qdata[order]
          return ldata, (irow, icol, qdata), ldata.dtype.type(self.offset)