code: def energy(self, spins, break_aux_symmetry=True):
          
          subtheta = self.theta.copy()
          subtheta.fix_variables(spins)
  
          # we need aux variables
          av = next(self._auxvar_counter)
          auxvars = {v: Symbol('aux{}_{}'.format(av, v), BOOL) for v in subtheta.linear}
          if break_aux_symmetry and av == 0:
              # without loss of generality, we can assume that the aux variables are all
              # spin-up for one configuration
              self.assertions.update(set(auxvars.values()))
  
          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(trees, {}, subtheta, auxvars), subtheta.offset)
  
          return energy
docs: A formula for the exact energy of Theta with spins fixed.
  
          Args:
              spins (dict): Spin values for a subset of the variables in Theta.
              break_aux_symmetry (bool, optional): Default True. If True, break
                  the aux variable symmetry by setting all aux variable to 1
                  for one of the feasible configurations. If the energy ranges
                  are not symmetric then this can make finding models impossible.
  
          Returns:
              Formula for the exact energy of Theta with spins fixed.