def to_hubo(self):
        """Construct a higher-order unconstrained binary optimization (HUBO)
        problem from a binary polynomial.

        Returns:
            tuple: A 2-tuple of the form (`H`, `offset`) where `H` is the HUBO
            and `offset` is the linear offset.

        """
        if self.vartype is Vartype.SPIN:
            return self.to_binary().to_hubo()

        H = {tuple(term): bias for term, bias in self.items() if term}
        offset = self[tuple()] if tuple() in self else 0
        return H, offset
def to_hubo ( self ) : if self . vartype is Vartype . SPIN : return self . to_binary ( ) . to_hubo ( ) H = { tuple ( term ) : bias for term , bias in self . items ( ) if term } offset = self [ tuple ( ) ] if tuple ( ) in self else 0 return H , offset
Construct a higher-order unconstrained binary optimization (HUBO)
        problem from a binary polynomial.

        Returns:
            tuple: A 2-tuple of the form (`H`, `offset`) where `H` is the HUBO
            and `offset` is the linear offset.