code: def invariant(arg1, arg2=None):
      
  
      desc = ""
      predicate = lambda x: x
  
      if isinstance(arg1, str):
          desc = arg1
          predicate = arg2
      else:
          desc = get_function_source(arg1)
          predicate = arg1
  
      def invariant(c):
          def check(name, func):
              exceptions = ("__getitem__", "__setitem__", "__lt__", "__le__", "__eq__",
                            "__ne__", "__gt__", "__ge__", "__init__")
  
              if name.startswith("__") and name.endswith("__") and name not in exceptions:
                  return False
  
              if not ismethod(func) and not isfunction(func):
                  return False
  
              if getattr(func, "__self__", None) is c:
                  return False
  
              return True
  
          class InvariantContractor(c):
              pass
  
          for name, value in [(name, getattr(c, name)) for name in dir(c)]:
              if check(name, value):
                  setattr(InvariantContractor, name,
                          condition(desc, predicate, name != "__init__", True, True)(value))
          return InvariantContractor
      return invariant
docs: Specify a class invariant described by `description` and tested
      by `predicate`.