code: def state(cls, obj, state=None):
          
          if state is None:
              ids = cls.capture_ids(obj)
              original_custom_keys = set(Store.custom_options().keys())
              return (ids, original_custom_keys)
          else:
              (ids, original_custom_keys) = state
              current_custom_keys = set(Store.custom_options().keys())
              for key in current_custom_keys.difference(original_custom_keys):
                  del Store.custom_options()[key]
                  cls.restore_ids(obj, ids)
docs: Method to capture and restore option state. When called
          without any state supplied, the current state is
          returned. Then if this state is supplied back in a later call
          using the same object, the original state is restored.