code: def retract(self, idx_or_fact):
          
  
          if isinstance(idx_or_fact, int):
              idx = idx_or_fact
          else:
              idx = idx_or_fact.__factid__
  
          if idx not in self:
              raise IndexError('Fact not found.')
  
          fact = self[idx]
  
          # Decrement value reference counter
          fact_id = self._get_fact_id(fact)
          self.reference_counter[fact_id] -= 1
          if self.reference_counter[fact_id] == 0:
              self.reference_counter.pop(fact_id)
  
          watchers.FACTS.info(" <== %s: %r", fact, fact)
          self.removed.append(fact)
  
          del self[idx]
  
          return idx
docs: Retract a previously asserted fact.
  
          See `"Retract that fact" in Clips User Guide
          <http://clipsrules.sourceforge.net/doc\
                  umentation/v624/ug.htm#_Toc412126077>`_.
  
          :param idx: The index of the fact to retract in the factlist
          :return: (int) The retracted fact's index
          :throws IndexError: If the fact's index providen does not exist