code: def safe_discard(self, state: InstanceState[Any]) -> None:
      key = state.key
      if key in self._dict:
          assert key is not None
          try:
              st = self._dict[key]
          except KeyError:
              # catch gc removed the key after we just checked for it
              pass
          else:
              if st is state:
                  self._dict.pop(key, None)
                  self._manage_removed_state(state)
  
imports: from __future__ import annotations
  from typing import Any
  from typing import cast
  from typing import Dict
  from typing import Iterable
  from typing import Iterator
  from typing import List
  from typing import NoReturn
  from typing import Optional
  from typing import Set
  from typing import Tuple
  from typing import TYPE_CHECKING
  from typing import TypeVar
  import weakref
  from .None import util
  from ..None import exc
label_desc: Use image node_id 15 for calling the WeakInstanceDict obj's underlying member method code with example usage: obj.safe_discard(state) without return types