code: def energy_upperbound(self, spins):
          
          subtheta = self.theta.copy()
          subtheta.fix_variables(spins)
  
          # ok, let's start eliminating variables
          trees = self._trees
  
          if not trees:
              # if there are no variables to eliminate, then the offset of
              # subtheta is the exact value and we can just return it
              assert not subtheta.linear and not subtheta.quadratic
              return subtheta.offset
  
          energy = Plus(self.message_upperbound(trees, {}, subtheta), subtheta.offset)
  
          return energy
docs: A formula for an upper bound on the energy of Theta with spins fixed.
  
          Args:
              spins (dict): Spin values for a subset of the variables in Theta.
  
          Returns:
              Formula that upper bounds the energy with spins fixed.